Transport error setting up Gmail in excel

MrCaptain

Board Regular
Joined
Dec 5, 2006
Messages
123
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

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]
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top