Ciao,
ho questo codice marco che genera una mail automatica attraverso un template pronto.
Non c'è nessun codice VBA, inoltre tieni a mente che la macro è l'insieme delle istruzioni VBA, Marco è un nome di persona.
In questo template rispetto a prima devo mettere dei caratteri in: grassetto, sottolineati, in rosso.
Genericamente, devi usare un body HTML ed usare i tag <b> e <i>, qui trovi indicazioni utili.
Ciao.
M scuso se ho scritto Marco invece che Macro, ovviamente la mia intenzione era scrivere quest'ultimo termine anziché il nome di persona.
Il codice macro che devo modificare è il seguente:
Sub InviaEmailFiltro()
Dim lngC As Long, lngR As Long, lngRows As Long, lngCols As Long
Dim blnF As Boolean, lngF As Long, strF As String, strH As String, strEmail As String
Dim olApp As Outlook.Application, dicF As Dictionary, varF
Dim mail As MailItem, strBody As String
Dim wksS As Worksheet, wksH As Worksheet
Set wksS = Worksheets("righe da sollecitare dali")
Set wksH = Worksheets("email da inviare")
Set dicF = New Scripting.Dictionary
With wksS
lngRows = .Range("B" & Rows.Count).End(xlUp).Row
If lngRows = 1 Then Exit Sub
For lngR = 2 To lngRows
If Not dicF.Exists(.Cells(lngR, 2).Value) And Not Rows(lngR).Hidden Then
dicF.Add .Cells(lngR, 2).Value, "e-" & .Cells(lngR, 2).Value
End If
Next lngR
End With
lngF = 2
For Each varF In dicF.Keys
strBody = Replace(Replace(wksH.Range("A1").Value, "Gentile fornitore,", "Gentile " & varF & ","), Chr(10), "<br>")
strEmail = "" 'dicF(varF)
strBody = strBody & "<table><thead><tr>"
lngC = 4
With wksS
Do Until .Cells(1, lngC).Value = ""
strBody = strBody & "<th>" & .Cells(1, lngC).Value & "</th>"
lngC = lngC + 1
Loop
lngCols = lngC - 1
strBody = strBody & "</tr></thead><tbody>"
lngRows = .Range("B" & Rows.Count).End(xlUp).Row
blnF = False
For lngR = 2 To lngRows
If UCase(.Cells(lngR, 3).Value) = UCase(varF) Then
blnF = True
strBody = strBody & "<tr>"
For lngC = 4 To lngCols
strBody = strBody & "<td>" & .Cells(lngR, lngC).Value & "</td>"
Next lngC
strBody = strBody & "</tr>"
End If
Next lngR
strBody = strBody & "</tbody></table>"
End With
If blnF Then
Set olApp = New Outlook.Application
Set mail = olApp.CreateItem(olMailItem)
With mail
.To = strEmail
.Subject = "Sollecito"
.HTMLBody = strBody
.Display
End With
Else
MsgBox "Nessun record trovato per il fornitore " & wksS.Range("L1").Value, vbCritical, "Fine"
End If
lngF = lngF + 1
Next varF
End Sub