![]() |
Send Workbook as an Attachment Via Gmail - Code Review
Hello,
Below is a code for sending workbook as an attachment. The below works fine but its not sending the workbook as an attachment. I get the email based on the parameters below, but its only the strbody message that comes through and nothing from the workbook. I would like the entire workbook (has only one worksheet) to come through as an attachment. And at the end of the loop, the workbook should save itself on the local desktop with filename&"_"&date (date mentioned in cell f1) and close. Sub CDO_Mail_Small_Text_2() Dim iMsg As Object Dim iConf As Object Dim strbody As String Dim Flds As Variant Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = " .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 .Update End With strbody = "Hi there" & vbNewLine & vbNewLine & _ "Daily Sheet Final" & vbNewLine & _ "Thanks" & vbNewLine & _ "Team A" & vbNewLine & _ "1234567890" With iMsg Set .Configuration = iConf .To = " .CC = "" .BCC = "" ' Note: The reply address is not working if you use this Gmail example ' It will use your Gmail address automatic. But you can add this line ' to change the reply address .ReplyTo = " .From = """YourName"" " .Subject = "Important message" .TextBody = strbody .Send End With End Sub |
Send Workbook as an Attachment Via Gmail - Code Review
Hi
If you have not been to Ron De Bruin's site then try this. It has a link to download a file with examples of how to set up a CDO using Gmail with attachments. http://www.rondebruin.nl/cdo.htm HTH Mick. |
All times are GMT +1. The time now is 04:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com