Ciao Alessandro,
CONFETRA
[Cut]
immediately to the sender and to erase the original message received. Thank you.
Per aggiungere anche questa tua firma di Outlook, prova a sostituire il codice precedente con la seguente versione:
'=========>>
Option Explicit
'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim RngTabella As Range
Dim arrTabella As Variant
Dim OutApp As Object
Dim OutMail As Object
Dim sHeader As String, sMsg As String, sFile As String
Dim sPath As String, sStr As String
Dim sBody As String
Dim LRow As Long, i As Long, j As Long
Const sSoggetto As String = "Cartelle in scadenza"
Const sGreeting As String = "All'attenzione di:"
Const sPercorso As String = "Z:\Protocollo 2015\Centro \Nota \Lettere"
Set WB = ThisWorkbook
Set SH = WB.Sheets("Campione")
With SH
LRow = LastRow(SH, .Columns("A:A"))
Set RngTabella = .Range("A2:L" & LRow)
End With
arrTabella = RngTabella.Value
On Error GoTo 0
With Application
sStr = .PathSeparator
.EnableEvents = False
.ScreenUpdating = False
End With
If Right(sPercorso, 1) = sStr Then
sPath = sPercorso
Else
sPath = sPercorso & sStr
End If
For i = 1 To UBound(arrTabella, 1)
sFile = arrTabella(i, 3) & ".xlsx"
sHeader = "Spett.le" _
& "<br>" _
& arrTabella(i, 4) _
& "<br>" _
& arrTabella(i, 6) _
& "<br>" _
& arrTabella(i, 7) _
& "<br>" _
& arrTabella(i, 8) _
& "<br>" & "<br>" _
& sGreeting _
& "<font color=""blue""><b>" _
& arrTabella(i, 5) _
& "</b></font><br><br>"
sMsg = arrTabella(i, 11) _
& "<br><br>" _
& "Ti trasmetto il questionario per la rilevazione " _
& "dei dati utili alla redazione della ????." _
& "<br><br>" _
& "Come in precedenza potrai compilarlo a mano e rinviarlo " _
& "via fax, oppure compilarlo, salvarlo e inviarlo via email; " _
& "lo stesso questionario è scaricabile collegandoTi all’indirizzo " _
& arrTabella(i, 12) _
& "<br><br>" _
& "Fiducioso di poter continuare a contare sulla Tua " _
& "collaborazione, attendo le risposte e Ti saluto cordialmente" _
& "<br><br>" _
& "Allegato: " & sFile
sBody = sHeader & "<br>" & sMsg
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Display
.To = arrTabella(i, 9)
.CC = arrTabella(i, 10)
.BCC = ""
.Subject = sSoggetto
.Attachments.Add sPath & sFile
.HTMLBody = sBody & "<br>" & .HTMLBody
.Send
End With
Set OutMail = Nothing
Next i
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
'--------->>
Public Function LastRow(SH As Worksheet, _
Optional Rng As Range)
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
End Function
'<<=========
===
Regards,
Norman