Ciao,
ti riporto uno stralcio da un mio Db:
Private Sub cmdInviaElenchi_Click()
Dim outApp As Object
Dim outMsg As Object
Dim resp As Variant
Dim i As Integer
Dim iMittente As Long
resp = MsgBox("Si confermano gli invii di EMail ?", vbOKCancel, "EMail agli xxxxxxx.")
If Not resp = vbOK Then
Beep
Exit Sub
End If
On Error Resume Next
Set outApp = GetObject(, "Outlook.Application") 'Se Outlook già attivo
If Err Then
Err.Clear
Set outApp = CreateObject("Outlook.Application") 'Apro nuova sessione di Outlook
End If
'Per tutti gli elementi in cboElenco compone una mail con il proprio allegato
For i = 0 To cboElenco.ListCount - 1
DoCmd.OpenReport "ReportName", acViewPreview, , Me.Filter & " And Left(xxxxxx,3) = '" & cboElenco.ItemData(i) & "'"
DoCmd.OutputTo acOutputReport, , DLookup("OOAK_FormatoAllegato", "OOAK"), _
"C:\TEMP\ReportName." & DLookup("OOAK_FormatoAllegato", "OOAK")
Set outMsg = outApp.CreateItem(olMailItem)
iMittente = DLookup("OOAK_From", "OOAK")
With outMsg
Set .SendUsingAccount = outApp.Session.Accounts.Item(iMittente)
.To = "E" & cboElenco.ItemData(i) & "******@xxxx.it"
.CC = DLookup("OOAK_CC", "OOAK") & " "
.BCC = DLookup("OOAK_CCn", "OOAK") & " "
.Subject = "Elenco di: " & cboElenco.ItemData(i) & " - " & DLookup("OOAK_Oggetto", "OOAK")
.Body = DLookup("OOAK_Testo", "OOAK")
.Attachments.Add "C:\TEMP\reportName." & DLookup("OOAK_FormatoAllegato", "OOAK")
.Send
End With
Set outMsg = Nothing
DoCmd.Close
Beep
Next i
Set outApp = Nothing
Beep
On Error GoTo 0
End Sub
Ciao Mimmo