Moderatori: Anthony47, Flash30005
Sub Inviamail()
Dim RNG As Range
Dim CEL As Range
Dim OutApp As Object
Dim OutMail As Object
Dim bodymail As String
Dim c As Integer
Set RNG = Range("h2:h57")
For Each CEL In RNG
If CEL.Value - Date = 60 Or CEL.Value - Date = 30 Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = CEL.Offset(0, 1).Value
.Subject = "SCADENZA" & " " & CEL.Offset(0, -3).Value
.Display
End With
End If
Next CEL
End Sub
Sub Inviamail()
Dim RNG As Range
Dim CEL As Range
Dim OutApp As Object
Dim OutMail As Object
Dim bodymail As String
Dim c As Integer
Dim testo As String
Set RNG = Range("h2:h57")
For Each CEL In RNG
If CEL.Value - Date = 60 Or CEL.Value - Date = 30 Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
testo = "Descrizione_scadenza: " & CEL.Offset(0, -2).Value & Chr(10) & "Possibilità contrattuale: " & CEL.Offset(0, -1).Value & Chr(10) & "Scadenza: " & CEL.Value
With OutMail
.To = CEL.Offset(0, 1).Value
.Subject = "SCADENZA" & " " & CEL.Offset(0, -3).Value
.Body = testo
.Display
End With
End If
Next CEL
End Sub
Sub RiepMail()
'vedi http://www.pc-facile.com/forum/viewtopic.php?f=26&t=108891
Dim OLook As Object
Dim MItem As Object
Dim CScad As Integer, mText As String
Dim MSubj As String, ColScad As String, I As Long, J As Long
Dim clStart As Long, clHead As Long, mCol As String, logCol As String
Dim preAvv As Long, preAvv2 As Long, colBody, Terminator As String
Dim CK As Long, cDest As String, fMex As String, scaMex As String
'
clStart = 2 '<<< La prima riga con dati
clHead = 1 '<<< La riga con le intestazioni
colBody = Array("F", "G", "H") '<<< Le colonne da riportare nelle mail
ColScad = "H" '<<< La colonna con le date di scadenza
mCol = "I" '<<< La colonna con gli indirizzi email
preAvv = 60 '<<< Giorni di primo preavviso
preAvv2 = 30 '<<< Giorni di secondo preavviso
logCol = "L" '<<< La colonna di servizio in cui si segneranno le mail inviate
MSubj = "Avviso Di Scadenze" '<<< Il Subject della mail
'
Set OLook = CreateObject("Outlook.Application")
'
For CK = clStart To Cells(Rows.Count, colBody(0)).End(xlUp).Row
If Application.WorksheetFunction.CountIf(Range(Cells(clStart, mCol), Cells(CK, mCol)), Cells(CK, mCol)) < 2 Then
cDest = Cells(CK, mCol)
CScad = 0
mText = "Elenco delle prossime scadenze: " & vbCrLf
For I = CK To Cells(Rows.Count, colBody(0)).End(xlUp).Row
scaMex = ""
If Cells(I, mCol) = cDest Then
If (Now + preAvv >= Cells(I, ColScad) Or Now + preAvv2 >= Cells(I, ColScad)) And (Cells(I, logCol).Value + 30) <= Now Then
CScad = CScad + 1
For J = LBound(colBody) To UBound(colBody)
scaMex = scaMex & Cells(I, colBody(J)) & " --- "
Next J
Cells(I, logCol) = Int(Now)
scaMex = scaMex & "Scadenza: " & Format(Cells(I, ColScad), "yyyy-mmm-dd") & vbCrLf & vbLf
End If
If Len(mText) > 3 Then mText = mText & scaMex
End If
Next I
Terminator = vbCrLf & "Servizio Automatico di alert" & vbCrLf '<<< Messaggio di coda
If CScad > 0 Then
Set MItem = OLook.createitem(0)
MItem.To = cDest
MItem.Subject = MSubj
MItem.body = mText & vbCrLf & Terminator
MItem.send
' MItem.display 'Test only
Application.Wait (Now + TimeValue("0:00:01"))
Set MItem = Nothing
fMex = fMex & vbCrLf & CScad & " scadenze per " & cDest
End If
End If
Next CK
If Len(fMex) < 5 Then fMex = "Nessuna scadenza da segnalare"
MsgBox ("Completato: " & vbCrLf & fMex)
Set OLook = Nothing
End Sub
Sub InvioEmail_Scad()
Dim cScad As Long, OLook As Object, mItem As Object, mText As String
'
cScad = Application.WorksheetFunction.CountIf(Range("D1:D10"), 5)
Set OLook = CreateObject("Outlook.Application")
If cScad > 0 Then
'Compilazione TEST del messaggio:
mText = "Buon giorno, sono la tua macro e ti invio questo promemoria" & vbCrLf '<<<
mText = mText & "Ci sono n° " & cScad & " scadenze tra 5 giorni" & vbCrLf '<<<
mText = mText & "Sai cosa fare..." '<<<
Set mItem = OLook.createitem(0)
mItem.To = Range("F10").Value
'Compilazione del Subject:
mItem.Subject = "Mail automatica per boh" '<<<
mItem.body = mText
mItem.send
' mItem.display 'Test only
Application.Wait (Now + TimeValue("0:00:02"))
Set mItem = Nothing
Set OLook = Nothing
MsgBox ("Inviata mail a " & Range("F10"))
Else
MsgBox ("Nessuna scadenza da segnalare")
End If
End Sub
Torna a Applicazioni Office Windows
Eliminare righe diverse dalla prima data del mese Autore: dipdip |
Forum: Applicazioni Office Windows Risposte: 4 |
Lo scanner della Pixma TS 5150 non parte Autore: wallace&gromit |
Forum: Assistenza Hardware Risposte: 9 |
Visitano il forum: Nessuno e 11 ospiti