Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 4
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using VBA to send out mail via gmail Webtechie Excel Programming 5 July 14th 09 08:22 PM
Using Excel to send email from gmail sun Excel Programming 1 January 9th 09 03:33 PM
Copy from Excel & paste directly to Gmail - instead of as attachment [email protected] Excel Discussion (Misc queries) 1 January 2nd 09 07:42 AM
Send active workbook as attachment OTTO Excel Programming 4 June 5th 04 10:06 AM


All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"