Emailing ActiveWorkBook with Gmail

RmBaugh

New Member
Joined
Feb 1, 2014
Messages
45
Guys,

I have pieced together a code using DeBruin's to send emails through Gmail.
I cannot for the life of me add the active workbook as an attachment.

As it currently runs, it attaches a blank attachment.
I have been working on this for hours, but cant get it worked out.:confused:

Appreciate any help.



Sub btnEmailBid_Click()
Dim Mail As New Message
Dim Config As Configuration
Set Config = Mail.Configuration


Config(cdoSendUsingMethod) = cdoSendUsingPort
Config(cdoSMTPServer) = "smtp.gmail.com"
Config(cdoSMTPServerPort) = 25
Config(cdoSMTPAuthenticate) = cdoBasic
Config(cdoSMTPUseSSL) = True
Config(cdoSendUserName) = "xxx@abc.com"
Config(cdoSendPassword) = "xxxx"
Config.Fields.Update


Mail.To = "xxx@abc.com"
Mail.From = Config(cdoSendUserName)
Mail.Subject = "New Bid - " & Range("f5").Value & " " & Range("f6")
Mail.TextBody = "Attached are copies of the bid and pics." & " " & vbNewLine & _
"Let me know if you have any questions." & vbNewLine & vbNewLine & _
"Thanks,"
Mail.AddAttachment ""


On Error Resume Next


Mail.Send


If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "There was an error."
Exit Sub
End If
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Is this possible?
I know I can send the attachment, just not the active workbook I'm working in.

Thanks
 
Upvote 0
Guys,

I have pieced together a code using DeBruin's to send emails through Gmail.
I cannot for the life of me add the active workbook as an attachment.

As it currently runs, it attaches a blank attachment.
I have been working on this for hours, but cant get it worked out.:confused:

Appreciate any help.



Sub btnEmailBid_Click()
Dim Mail As New Message
Dim Config As Configuration
Set Config = Mail.Configuration


Config(cdoSendUsingMethod) = cdoSendUsingPort
Config(cdoSMTPServer) = "smtp.gmail.com"
Config(cdoSMTPServerPort) = 25
Config(cdoSMTPAuthenticate) = cdoBasic
Config(cdoSMTPUseSSL) = True
Config(cdoSendUserName) = "xxx@abc.com"
Config(cdoSendPassword) = "xxxx"
Config.Fields.Update


Mail.To = "xxx@abc.com"
Mail.From = Config(cdoSendUserName)
Mail.Subject = "New Bid - " & Range("f5").Value & " " & Range("f6")
Mail.TextBody = "Attached are copies of the bid and pics." & " " & vbNewLine & _
"Let me know if you have any questions." & vbNewLine & vbNewLine & _
"Thanks,"
Mail.AddAttachment ""




On Error Resume Next


Mail.Send


If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "There was an error."
Exit Sub
End If

This is where I am having issues. Any time it is something other than the parenthesis, I get an error.
I know it is something simple that I am overlooking.

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

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