Hi experts,
I have not seen a solution to my problem anywhere, I am trying to setup an e-mail in excel using Gmail and it fails with the message "The transport error code was 0x80040217"
Username and password is correct in real version. Do I need to somehow add the server name with 'Mail.Send'?
Here's my code, I have enabled Microsoft CDO for Windows 2000 library.
Regards,
Vern
I have not seen a solution to my problem anywhere, I am trying to setup an e-mail in excel using Gmail and it fails with the message "The transport error code was 0x80040217"
Username and password is correct in real version. Do I need to somehow add the server name with 'Mail.Send'?
Here's my code, I have enabled Microsoft CDO for Windows 2000 library.
Regards,
Vern
Code:
[TABLE="width: 557"]
<tbody>[TR]
[TD][B]Private Sub cmdSendEmail_Click()[/B][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Dim Mail As New message[/TD]
[/TR]
[TR]
[TD]Dim Config As Configuration[/TD]
[/TR]
[TR]
[TD]Set Config = Mail.Configuration[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Config(cdoSendUsingMethod) = cdoSendUsingPort[/TD]
[/TR]
[TR]
[TD]Config(cdoSMTPServer) = "smtp.Gmail.com"[/TD]
[/TR]
[TR]
[TD]Config(cdoSMTPAuthenticate) = 25[/TD]
[/TR]
[TR]
[TD]Config(cdoSMTPAuthenticate) = cdoBasic[/TD]
[/TR]
[TR]
[TD]Config(cdoSMTPUseSSL) = True[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Config(cdoSendUserName) = "myusername"[/TD]
[/TR]
[TR]
[TD]Config(cdoSendPassword) = "mypassword"[/TD]
[/TR]
[TR]
[TD]Config.Fields.Update[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Mail.To = "recipient email address"[/TD]
[/TR]
[TR]
[TD]Mail.From = Config(cdoSendUserName)[/TD]
[/TR]
[TR]
[TD]Mail.Subject = "Email Subject"[/TD]
[/TR]
[TR]
[TD]Mail.HTMLBody = "[B]EmailBody[/B]"[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]On Error Resume Next[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Mail.Send[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]If Err.Number <> 0 Then[/TD]
[/TR]
[TR]
[TD][B]MsgBox Err.Description, vbCritical, "There was an error"[/B][/TD]
[/TR]
[TR]
[TD]Exit Sub[/TD]
[/TR]
[TR]
[TD]End If[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]MsgBox "Your e-mail has been sent!", vbInformation, "Sent"[/TD]
[/TR]
</tbody>[/TABLE]