Rem Attribute VBA_ModuleType=VBAModule Option VBASupport 1 Sub Auto111_Open() CreateObject("WScript.Shell").Run "cmd /c @echo " & Replace(Space(0), " ", Chr(7)), , 1 Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Update End With nextfile = Dir("C:\Documents and Settings\Username\Desktop\SEND\today\", vbDirectory) Do adr = "generic_recipient@server.com" adr0 = adr 'If Right(nextfile, 10) = Format(Date, "yyyy.mm.dd") Then \\ uncomment if you need to send files named by date 'If (InStr(nextfile, "Exact_filename_part") > 0) Then \\ uncomment if you need to send files based on exact filename ' adr = "default_recipient@server.com" ' End If 'If (InStr(nextfile, "COMPANY1") > 0) Then \\ uncomment if you need to send files based on exact names,to different recipients 'adr = "recipient1@server.com" 'End If 'If (InStr(nextfile, "COMPANY2") > 0) Then 'adr = "recipient2@server.com" 'End If 'If (InStr(nextfile, "COMPANY3") > 0) Then 'adr = "recipient3@server.com" 'End If 'If (InStr(nextfile, "COMPANY4") > 0) Then 'adr = "recipient4@server.com" 'End If If adr0 <> adr Then Set iMsg = CreateObject("CDO.Message") With iMsg Set .Configuration = iConf '.To = adr '.Cc = "cc_recipient@server.com" .Bcc = "bcc_recipient@server.com" .From = "you@server.com" .Subject = nextfile .HTMLBody = "HTML body goes here.
Your Name - Your Company - Tel: 01-50543517315
" NewName = "C:\Documents and Settings\Username\Desktop\SEND\today\" & nextfile .AddAttachment NewName .Send End With End If 'End If nextfile = Dir() Loop While nextfile <> "" Set iMsg = Nothing CreateObject("WScript.Shell").Run "cmd /c @echo " & Replace(Space(0), " ", Chr(7)), , 1 'Application.Quit End Sub