- Codice: Seleziona tutto
Sub send_gmail()
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "miamail@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "miapassw"
.Update
End With
strbody = "testo da inviare"
With cdomsg
.To = "destinatario@inwind.it"
.From = "miamail@gmail.com"
.Subject = "soggetto"
.TextBody = strbody
.CC = ""
.BCC = ""
.AddAttachment "C:\duplicati1.xls"
.Send
End With
Set cdomsg = Nothing
End Sub