In this article we are going to show how to Email Using CDO.Message Object With Attachment
Set Mail = CreateObject(“CDO.Message”)
‘This section provides the configuration information for the remote SMTP server.
‘Send the message using the network (SMTP over the network).
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")
="smtp.hayleys.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (True or False)
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontim eout") = 60
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="username"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password"
Mail.Configuration.Fields.Update
'End of remote SMTP server configuration section
Mail.Subject="Subject "
Mail.From="from@gmail.com"
Mail.To="to@gmail.com"
Mail.TextBody="Body"
Mail.AddAttachment "FilePath" + FileName+ ".pdf"
Mail.Send
Set Mail = Nothing
Send Email Using CDO.Message Object With Attachment