I have the following code of which I have a button on a excel worksheet that is supposed to email the active sheet. I can get the email. I can even get attachments. I just can't get it to work properly with the active sheet. Any help would be greatly appreciated.
Thanks
Thanks
Code:
Sub SendMail()
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") = "Full Email Address"
.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") = 25
.Update
End With
strbody = "Attached you will find last nights numbers"
& vbNewLine
& vbNewLine & _
"Thanks" & vbNewLine & _
& vbNewLine & _
"Lee"
ActiveWorkbook.save
CurrFile = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With iMsg
Set .Configuration = iConf
.To = EmailAddress@gggg.com
.CC = ""
.BCC = ""
.From = """Name"" <Email@Email.com>"
.Subject = "Closing Numbers"
.Attachment.Add = CurrFile
.Send
End With
End Sub