P
psanghvi
Hello,
Below is a code for sending workbook as an attachment. The below work
fine but its not sending the workbook as an attachment. I get the emai
based on the parameters below, but its only the strbody message tha
comes through and nothing from the workbook. I would like the entir
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 loca
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")
"(e-mail address removed)"
.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 = "(e-mail address removed)"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmai
example
' It will use your Gmail address automatic. But you can ad
this line
' to change the reply address .ReplyTo = "(e-mail address removed)"
.From = """YourName"" <[email protected]>"
.Subject = "Important message"
.TextBody = strbody
.Send
End With
End Su
Below is a code for sending workbook as an attachment. The below work
fine but its not sending the workbook as an attachment. I get the emai
based on the parameters below, but its only the strbody message tha
comes through and nothing from the workbook. I would like the entir
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 loca
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")
"(e-mail address removed)"
.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 = "(e-mail address removed)"
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmai
example
' It will use your Gmail address automatic. But you can ad
this line
' to change the reply address .ReplyTo = "(e-mail address removed)"
.From = """YourName"" <[email protected]>"
.Subject = "Important message"
.TextBody = strbody
.Send
End With
End Su