Dim OutApp As Object
Dim OutMail As Object
Dim nomefiledaallegare As String
Dim testoMail As String
Dim FIRME As String
Dim SIGNATURE As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
FIRME = "C:\Documents and Settings\XXXXXXXXXXXXXXXXXXX\Dati applicazioni\Microsoft\Firme elettroniche\xxxxxx.htm"
If Dir(FIRME) <> "" Then
SIGNATURE = GetBoiler(FIRME)
Else
SIGNATURE = ""
End If
testoMail = "<html><head></head><body>"
testoMail = testoMail & "Ciao<br>"
testoMail = testoMail & "Prova invio mail da outlook con VB6."
testoMail = testoMail & "</body></html>" & " " & SIGNATURE
On Error Resume Next
With OutMail
.display
.To = "destinatario@itn.it"
.CC = ""
.BCC = ""
.Subject = "Prova invio mail da outlook con VB6."
.HTMLbody = testoMail
.Attachments.Add nomeFile
'.send
.Readreceiptrequested = False
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Private Sub Command1_Click()
inviaMail
End Sub
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Nessun commento:
Posta un commento