Našel jsem toto. Je to pro gmail, ale nejsem z toho moudrý. Šlo by to nějak zbastlit dohromady?
https://www.launchexcel.com/sending-e-mails-from-gmail-and-outlook-using-excel-vba/#gmail
Sub SendGmail()
'creating a CDO object
Dim Mail As CDO.Message
Set Mail = New CDO.Message
'Enable SSL Authentication
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
'Make SMTP authentication Enabled=true (1)
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Set the SMTP server and port Details
'Get these details from the Settings Page of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtp.gmail.com"
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Set your credentials of your Gmail Account
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = _
"username@gmail.com"
Mail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _
"*********"
'Update the configuration fields
Mail.Configuration.Fields.Update
'Set All Email Properties
With Mail
.Subject = "Write subject here"
.From = "username@gmail.com"
.To = "user1@gmail.com;user4@gmail.com"
.CC = "user2@gmail.com"
.BCC = "user3@gmail.com"
.textbody = "write your mail here"
.AddAttachment ("Folder Address") 'To attach Documents in mail
End With
'to send the mail
Mail.Send
End Sub
citovat