Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set fso=CreateObject("Scripting.FileSystemObject")
- strSMTP="smtp.gmail.com"
- strSubject="mail@gmail.com"
- strSubject2="Attachment file"
- strBody="-"
- strAttach="FILEPATH"
- If fso.FileExists(strAttach) then
- Set iMsg = CreateObject("CDO.Message")
- 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") = strSMTP
- .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
- .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
- .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mail@gmail.com"
- .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
- .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
- .Update
- End With
- With iMsg
- Set .Configuration = iConf
- .To = "mail2@gmail.com"
- .CC = ""
- .BCC = ""
- .From = "mail1@gmail.com"
- .Subject = strAttach
- .TextBody = strBody
- .AddAttachment strAttach
- .Send
- End With
- Set iMsg = Nothing
- Set iConf = Nothing
- Else
- MsgBox "The specified attachment does not exist"
- End if
Add Comment
Please, Sign In to add comment