PS ecco il codice che uso
- Codice: Seleziona tutto
Sub PROVAMAIL2007b()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
Const LF = vbCrLf
' (a)
'PERCORSOFILEIMMAGINE = """C:\io.JPG"""
Set OutApp = CreateObject("Outlook.Application")
''compilazione del testo di accompagnamento
OutFile = Cells(Range("G4").Value, "O").Value
For I = 5 To Range("H100").End(xlUp).Row
BDT = BDT & Cells(I, "H").Value & LF
Next I
'' (b)
Nominat = Cells(Range("G4").Value, "A").Value
EmailAddr = Cells(Range("G4").Value, "B").Value
Subj = Range("H4").Value
'
EmailAddr1 = Cells(Range("G4").Value, "C").Value
Subj = Range("H4").Value
EmailAddr2 = Cells(Range("G4").Value, "D").Value
Subj = Range("H4").Value
'
'IMMAGINE = "<BR>" & "<img src=" & PERCORSOFILEIMMAGINE & "/></b><br>"
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = EmailAddr
.CC = EmailAddr1 & ";" & EmailAddr2
.BCC = ""
.Subject = Subj
If Cells(Range("G4").Value, "O").Value <> "" Then
.Attachments.Add OutFile
End If
.Body = BDT & IMMAGINE
.send
'.Display 'or use .send
'.send
End With
' (c)
Set OutMail = Nothing
'
' (d)
Set OutApp = Nothing
End Sub