Hi all,
I am using the following code to send out automatic emails containing some text in the body of the email plus an attachment and this works perfectly:
TempFilePath = Environ$("temp") & "\"
TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.To = Email
.CC = ""
.BCC = ""
.Subject = "File Name"
.Body = strbody & strbody1
.Attachments.Add Dest.FullName
.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
Is it possible to insert a picture into the body of the email. I can't come up with any coding that would suit. Can anyone help!!
What I would envisage needs to happen is that the picture would need to go with the email as an attachment and when it's opened it would need to be embedded in the body of the email. This is an important step, as we know that if this goes as an attachment only, this attachment wouldn't be opened by the recipients. We need them to see the data on opening the email!!
rgs
Ginny
I am using the following code to send out automatic emails containing some text in the body of the email plus an attachment and this works perfectly:
TempFilePath = Environ$("temp") & "\"
TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.To = Email
.CC = ""
.BCC = ""
.Subject = "File Name"
.Body = strbody & strbody1
.Attachments.Add Dest.FullName
.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
Is it possible to insert a picture into the body of the email. I can't come up with any coding that would suit. Can anyone help!!
What I would envisage needs to happen is that the picture would need to go with the email as an attachment and when it's opened it would need to be embedded in the body of the email. This is an important step, as we know that if this goes as an attachment only, this attachment wouldn't be opened by the recipients. We need them to see the data on opening the email!!
rgs
Ginny