dopo un pò di tempo eccomi di nuovo qui con un nuovo problema:
Ho creato una macro in un foglio excel (sbirciando vecchi topic) che invia automaticamente un e-mail con delle date di scadenza ed altre informazioni relative alla data.
Con questo codice però la mail viene inviata ogni volta che io apro il file, mentre io vorrei inviarla indipendentemente dall'apertura del file excel, per esempio ogni volta che vi è una nuova scadenza.
Qui di seguito trovate il codice che ho scritto:
- Codice: Seleziona tutto
Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim EmailAddrCC As String
Dim Subj As String
Dim BodyText As String
EmailAddr = "xxx@xxx.it"
EmailAddrCC = "xxxx@xxxx.it"
Subj = "Scadenze"
BodyText = "Buongiorno," & Chr(10) & "si ricorda che stanno scadendo:" & Chr(10)
For RR = 9 To 100
If Cells(RR, 9).Value = "" Then GoTo avanti
If Cells(RR, 9).Value = "EXPIRED" Then
BodyText = BodyText & Cells(RR, 14).Value & "," & Chr(10)
Else
End If
Next RR
avanti:
BodyText = BodyText & Chr(10) & "Saluti," & Chr(10) & "nome"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = EmailAddr
.CC = EmailAddrCC
.BCC = ""
.Subject = Subj
.Body = BodyText
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub
Sapete aiutarmi? grazie mille