Moderatori: Anthony47, Flash30005
Sub Invioemail()
'Vedi http://www.pc-facile.com/forum/viewtopic.php?f=26&t=104487
Dim OutApp As Object, OutMail As Object
Dim EmailAddr As String, Subj As String
Dim BDT As String, I As Long, myCnt As Long 'FIN QUI SONO "DICHIARAZIONI"
' (a)
Sheets("Foglio2").Select '<<< Il tuo Foglio con i nominativi e le date
'compilazione del testo della mail
BDT = "Elenco dei nominativi in scadenza al " & Format(Date, "yyyy-mmm-dd") & vbCrLf
For I = 2 To Cells(Rows.Count, "K").End(xlUp).Row
If IsDate(Cells(I, "K").Value) Then
If Cells(I, "K") = Date Then
BDT = BDT & Cells(I, "B") & vbCrLf
myCnt = myCnt + 1
End If
End If
Next I
BDT = BDT & vbCrLf & "Cordiali saluti" & vbCrLf
BDT = BDT & "La tua macro"
'' (b)
If myCnt = 0 Then Exit Sub 'Nessuna scadenza, si termina senza azioni
'
'DA QUI SI CREA E INVIA LA MAIL:
Set OutApp = CreateObject("Outlook.Application")
EmailAddr = "TuaEmail@Dominio.Com" '<<< INDIRIZZO EMAIL
Subj = "Scadenze del " & Format(Date, "yyyy-mmm-dd") ' OGGETTO DELLA MAIL
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = EmailAddr
.CC = ""
.BCC = ""
.Subject = Subj
.Body = BDT
'.Display 'or use .send
.send
End With
' (c)
Set OutMail = Nothing
' (d)
Set OutApp = Nothing
'
Application.Wait (Now + TimeValue("0:00:02"))
End SubPrivate Sub Workbook_Open()
Call Invioemail
End Sub
Sheets("Foglio2").Select '<<< Il tuo Foglio con i nominativi e le date
Sub Macro1()
Sheets("PrimoFoglio").Select '<<< Il tuo Foglio con i nominativi e le date
Call Invioemail
End sub
Sub Macro2()
Sheets("AltroFoglio").Select '<<< Il tuo Foglio con i nominativi e le date
Call Invioemail
End sub
If Cells(I, "K") = Date and Cells(I, "Z") = "" Then
Cells(I, "Z").value = DateTorna a Applicazioni Office Windows
| Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
| Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Visitano il forum: Nessuno e 13 ospiti