buona sera
avevo un attimo di tempo e ho provato
- Codice: Seleziona tutto
Option Explicit
Sub InviaEmail()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Bonus As String
Dim Msg As String
Dim miorange As Range
Dim flag As Range
Dim ur As Long
ur = Sheets("evasi").Range("a" & Rows.Count).End(xlUp).Row
Set miorange = Range("a1:a" & ur)
Set flag = Range("f1:f" & ur)
Set OutlookApp = CreateObject("Outlook.Application")
For Each cell In Range("f2:f" & ur)
If cell.Value = "Sollecitare" And _
cell.Value <> "Avvisato" Then
Subj = "SOLLECITO"
EmailAddr = Cells(ur, 5).Value
Msg = Range("a" & cell.Row).Value & " " & Range("b" & cell.Row).Value & " " & Range("c" & cell.Row).Value & " " & Range("d" & cell.Row).Value & " " & Range("e" & cell.Row).Value & " " & Range("f" & cell.Row).Value & " " & Range("g" & cell.Row).Value & " " & Range("h" & cell.Row).Value & " " & Range("i" & cell.Row).Value & " " & Range("j" & cell.Row).Value & " " & Range("k" & cell.Row).Value & " " & Range("l" & cell.Row).Value & " " & Range("m" & cell.Row).Value & " " & Range("n" & cell.Row).Value
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
'.Send
End With
End If
Next
Set OutlookApp = Nothing
End Sub
sicuramente Alfre e ricky sapranno sistemare meglio il mio "pasticcio" non posso provarlo perché su questo computer da dove Vi scrivo non ho outlook
in questo esempio sarà necessario andare poi ad inserire la descrizione "avvisato" dopo aver spedito le mail di sollecito in colonna F
così se in colonna F trova la parola avvisato non viene spedito nulla
Si potrebbe cancellare la formula e sostituire con "avvisato"
- Codice: Seleziona tutto
For Each cell In Range("f2:f" & ur)
If cell.Value = "Sollecitare" And _
cell.Value <> "Avvisato" Then
in alternativa si può aggiungere alla fine del ciclo di creazione
cells (i, 13). value = "avvisato" e naturalmente poi bisogna modificare il pezzo sopra
p.s : secondo il mio modesto parere ci potrebbe essere ancora una condizione che non mi sembra sia stata prevista:
e se la cella di colonna F è Blanck ??
lascio a voi le prove e ai guru di VBA la correzione e la proposta di splendide soluzioni che andrò a studiare nei prossimi giorni
buona serata a tutti