Hi there,
I have the following code that allows me to send a e-mail with an attach.
I've already chose the signature and the text that will show in the e-mail body.
I now found a problem, i need to insert 2 images in the e-mail body (one above the text and the other one below. Is there any way to do this? Can anyone help me?
My actual code:
Sub Rectânguloarredondado1_Clique()
'Working in 2000-2010
Dim Source As Range
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim OutApp As Object
Dim OutMail As Object
Dim SigString As String
Dim Signature As String
Set Source = Nothing
On Error Resume Next
Set Source = Range("N1:U100").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, " & _
"please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = wb.Name & " " _
& Format(Now, "dd-mmm-yy")
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007-2010
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
SigString = "C:\Documents and Settings\" & Environ("username") & _
"\Application Data\Microsoft\Signatures\Parcerias.txt"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
With OutMail
.To = "whatever@whatever.pt"
.CC = ""
.BCC = ""
.Subject = "Relance de Propostas Pré-Aprovadas"
.Body = "Caro Parceiro," & vbNewLine & vbNewLine & _
"Enviamos abaixo os Prospects que se encontram no estado Pré-Aprovados, há mais de 4 dias." & vbNewLine & _
"Agradecemos que verifique se os mesmos já foram enviados para a XX." & vbNewLine & _
"Caso ainda não tenham sido, solicitamos-lhe que o faça a fim de ser dada uma decisão." & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & Signature
.Attachments.Add Dest.FullName
'You can add other files also like this
'.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
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Bookmarks