Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Geacs,
Avevo trascurato la possibilità che alcuni destinatari possano ricevere meno allegati!
Pertanto sostituisci il codice con:
'========>>
Option Explicit
'-------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim arrIn As Variant
Dim oOutlook As Object
Dim oMail As Object
Dim sIndirizzo As String
Dim sNome As String
Dim sCognome As String
Dim sTitolo As String
Dim sPercorso As String
Dim sAllegato As String, sAllegato2 As String
Dim sAllegato3 As String, sAllegato4 As String, sAllegato5 As String
Dim sbody As String
Dim LRow As Long, i As Long
Const sFoglio As String = **"Foglio1" '<<=== Modifica**
Const sOggetto As String = **"Vote for Trump" '<<=== Modifica**
Const sEmailContatto As String = **"provachiocciola.hotmail.com" '<<=== Modifica**
Set WB = ThisWorkbook
Set SH = WB.Sheets(sFoglio)
With SH
LRow = LastRow(SH, .Columns("A:A"))
Set Rng = .Range("A2:J" & LRow)
End With
arrIn = Rng.Value2
Set oOutlook = CreateObject("Outlook.Application")
For i = 1 To UBound(arrIn)
Set oMail = oOutlook.CreateItem(0)
With oMail
sIndirizzo = arrIn(i, 1)
sCognome = arrIn(i, 2)
sNome = arrIn(i, 3)
sTitolo = arrIn(i, 4)
sPercorso = arrIn(i, 5)
sAllegato = arrIn(i, 6)
sAllegato2 = arrIn(i, 7)
sAllegato3 = arrIn(i, 8)
sAllegato4 = arrIn(i, 9)
sAllegato5 = arrIn(i, 10)
sbody = "<H3><B>Gentile " & sNome & " " \_
& sCognome & ",</B></H3>" & \_
"la tua iscrizione al corso XXYY di Volley del " & \_
"25 febbraio 2018" & \_
" presso l'istituto ZZKK sito in via Padova, 40 a Milano" & \_
" è stata registrata." & \_
"<br><br>Per confermare l'iscrizione è necessario effettuare" & \_
" il pagamento entro e non oltre domenica 18 febbraio 2018." & \_
"<br><br>Per qualsiasi chiarimento o dubbio, contatta " & \_
"la Segreteria allo 02/xxxxxxxx o scrivi a:" & Space(1) & \_
" <B>" & sEmailContatto & "</B>" & \_
"<br><br>Cordiali saluti<br>" & \_
"<br><B>Cognome nome</B><br>" & \_
"Segreteria di direzione" & \_
"<br>Nome Azienda<br>" & \_
"N°telefono<br>" & \_
"sito web<br>" & \_
"indirizzo mail<br>"
.To = sIndirizzo
.CC = ""
.BCC = ""
.Subject = sOggetto
.HTMLBody = sbody & "<br>" & .HTMLBody
.Attachments.Add sPercorso \_
& Application.PathSeparator \_
& sAllegato
If sAllegato2 <> vbNullString Then
.Attachments.Add sPercorso \_
& Application.PathSeparator \_
& sAllegato2
End If
If sAllegato3 <> vbNullString Then
.Attachments.Add sPercorso \_
& Application.PathSeparator \_
& sAllegato3
End If
If sAllegato4 <> vbNullString Then
.Attachments.Add sPercorso \_
& Application.PathSeparator \_
& sAllegato4
End If
If sAllegato5 <> vbNullString Then
.Attachments.Add sPercorso \_
& Application.PathSeparator \_
& sAllegato5
End If
.display 'Send
End With
Set oMail = Nothing
Next i
Set oMail = Nothing
Set oOutlook = Nothing
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range, \_
Optional minRow As Long = 1)
If Rng Is Nothing Then
Set Rng = SH.Cells
End If
On Error Resume Next
LastRow = Rng.Find(What:="\*", \_
After:=Rng.Cells(1), \_
Lookat:=xlPart, \_
LookIn:=xlFormulas, \_
SearchOrder:=xlByRows, \_
SearchDirection:=xlPrevious, \_
MatchCase:=False).Row
On Error GoTo 0
If LastRow < minRow Then
LastRow = minRow
End If
End Function
'<<========
===
Regards,
Norman