alexnkc
07-08-2017, 12:31 AM
Hi,
Help needed on fixing the problem on sending email from Excel.
I try to send email (Hotmail or Gmail) from Excel. I do some google and reference code from google and do some modification to suit my need.
Below are the code that I use and it was not success with error (picture below)
I try and error to fix it (like change the Server Port, SSL -true/false,...) but could not solve it.
19693
Dim Hotmail_Prep As CDO.Message
Set Hotmail_Prep = New CDO.Message
With Hotmail_Prep
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.live.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 '25 '465 '587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@hotmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ZZZ"
.Update
End With
.Subject = "Test Email"
.From = "***@hotmail.com"
.To = "yyy@hotmail.com"
.TextBody = "Good morning!"
End With
'On Error Resume Next
Hotmail_Prep.Send
MsgBox ("Mail has been sent")
Set Hotmail_Prep = Nothing
Thanks,
KC
Help needed on fixing the problem on sending email from Excel.
I try to send email (Hotmail or Gmail) from Excel. I do some google and reference code from google and do some modification to suit my need.
Below are the code that I use and it was not success with error (picture below)
I try and error to fix it (like change the Server Port, SSL -true/false,...) but could not solve it.
19693
Dim Hotmail_Prep As CDO.Message
Set Hotmail_Prep = New CDO.Message
With Hotmail_Prep
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.live.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 '25 '465 '587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@hotmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ZZZ"
.Update
End With
.Subject = "Test Email"
.From = "***@hotmail.com"
.To = "yyy@hotmail.com"
.TextBody = "Good morning!"
End With
'On Error Resume Next
Hotmail_Prep.Send
MsgBox ("Mail has been sent")
Set Hotmail_Prep = Nothing
Thanks,
KC