
Sub Before_Close()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
Dim rng As Range, data1 As Date, data2 As Date, cella
Set rng = Range("d4:D1000")
data1 = Date - 30
data2 = Date
For Each cella In rng
If cella >= data1 Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
' La colonna "B" contiene gli indirizzi e-mail dei vari destinatari mi dovrebbe selezionare solo quelli dal comando if, non tutti
.To = cella(0, -1)
' La colonna "C" contiene l'indirizzo e-mail in "Copia per Conoscenza"
.CC = "varesi.f@xxx.it"
.Subject = cella(0, 2)
' La colonna "E" contiene l testo della e-mail
.Body = "THE PROCEDURE IN THE TITLE IS GOING TO EXPIRE or IS ALREADY EXPIRED"
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.SendKeys "%a"
End If
Next
End Sub
|
Sub Mail()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''' ATTENZIONE RICHIEDE L'ATTIVAZIONE DELLA LIBRERIA MICROSOFT OUTLOOK 14.0 OBJECT LIBRARY '''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''' Per l'attivazione andare su "Strumenti", "Riferimenti", cercare e spuntare il nome '''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim indirizzo As String
Dim oOUT As Outlook.Application
Dim oML As MailItem
Dim messaggio As String
Dim oggetto As String
Dim rngC As Range, cella As Range
Set rngC = Range("D1:D10")
messaggio = "tuo messaggio"
oggetto = "tuo oggetto"
Set oOUT = CreateObject("Outlook.Application")
For Each cella In rngC
Set oML = oOUT.CreateItem(olMailItem)
'If condizione then
indirizzo = cella.Text
With oML
'.Attachments.Add ("C: uo_file.pdf")
.To = indirizzo
.Subject = oggetto
.Body = messaggio
'.SentOnBehalfOfName = "ilmio@mittente.com"
.Display
'.Send
End With
'End If
Next cella
Set rngC = Nothing
Set oOUT = Nothing
Set oML = Nothing
End Sub
|
Sub Mail()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''' ATTENZIONE RICHIEDE L'ATTIVAZIONE DELLA LIBRERIA MICROSOFT OUTLOOK 14.0 OBJECT LIBRARY '''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''' Per l'attivazione andare su "Strumenti", "Riferimenti", cercare e spuntare il nome '''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim indirizzo As String
Dim oOUT As Outlook.Application
Dim oML As MailItem
Dim messaggio As String
Dim oggetto As String
Dim rngC As Range, cella As Range
Set rngC = Range("D1:D38")
oggetto = "Spam!"
messaggio = "Sono un Pirla!"
Set oOUT = CreateObject("Outlook.Application")
For Each cella In rngC
Set oML = oOUT.CreateItem(olMailItem)
'If condizione then
indirizzo = cella.Text
With oML
'.Attachments.Add ("C: uo_file.pdf")
.To = indirizzo
.Subject = oggetto & cella.Row
.Body = messaggio & cella.Row
'.SentOnBehalfOfName = "ilmio@mittente.com"
.Display
.Send
End With
'End If
Next cella
Set rngC = Nothing
Set oOUT = Nothing
Set oML = Nothing
End Sub |
Sub Before_Close()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
Dim rng As Range, data1 As Date, data2 As Date, cella
Set rng = Range("d4:D1000")
data1 = Date - 30 'cioè da un mese prima di oggi mi serve perchè dovrebbe avvisare in anticipo che un ogetto è in scadenza'
For Each cella In rng
'ora mi dovrebbe mandare le email solo per gli articoli che risultano in scadenza, come nella colonna H,
'infatti ci sono tre expired mentre il codice manda 26 mail, ovvero a tutte le linee e non solo a quelle 3
If cella >= data1 Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
' La colonna "B" contiene gli indirizzi e-mail dei vari destinatari
.To = cella(0, -1)
' La colonna "C" contiene l'indirizzo e-mail in "Copia per Conoscenza"
.CC = "varesi.f@fater.it"
.Subject = cella(0, 2)
' La colonna "E" contiene l testo della e-mail
.Body = "THE PROCEDURE IN THE TITLE IS GOING TO EXPIRE or IS ALREADY EXPIRED"
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.SendKeys "%a"
End If
Next
End Sub |
Sub Before_Close()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
Dim rng As Range, data1 As Date, data2 As Date, cella
Set rng = Range("d4:D100")
data1 = Date + 30 'cioè da un mese prima di oggi mi serve perchè dovrebbe avvisare in anticipo che un ogetto è in scadenza'
For Each cella In rng
'ora mi dovrebbe mandare le email solo per gli articoli che risultano in scadenza, come nella colonna H,
'infatti ci sono tre expired mentre il codice manda 26 mail, ovvero a tutte le linee e non solo a quelle 3
If cella <= data1 And cella <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
' La colonna "B" contiene gli indirizzi e-mail dei vari destinatari
.To = cella(1, -1)
' La colonna "C" contiene l'indirizzo e-mail in "Copia per Conoscenza"
.CC = "varesi.f@fater.it"
.Subject = cella(1, 2)
' La colonna "E" contiene l testo della e-mail
.Body = "THE PROCEDURE IN THE TITLE IS GOING TO EXPIRE or IS ALREADY EXPIRED"
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Application.SendKeys "%a"
End If
Next
End Sub
|
