
Sub inviamail()
Application.ScreenUpdating = False
Dim OutApp As Object
Dim EmailAddr As String
Dim subj As String
Dim BodyText As String
Foglio1.Select
Range("I2:I6500").Activate
Range("I2:I6500").NumberFormat = "#.##0,00"
Range("J2:J6500").NumberFormat = "mmmm/yyyy"
Range("O:P").ClearContents
rr = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To rr
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.Createitem(0)
'On Error Resume Next
With OutMail
.To = Cells(i, 2)
.cc = Cells(i, 3)
.bcc = ""
.Subject = Cells(i, 4)
.body = "test invio e-mails"
'Cells(I, 5) & Trim(Cells(I, 8)) & " " & "test e prova"
.attachments.Add (Cells(i, 6) & Cells(i, 7))
'.display questo comando visualizza la finestra del messaggio di outlook e in caso di
' invio di email multiple fa sfarfallare il monitor
.send
Application.SendKeys "%I" ' non fa uscire la finestra di Outlook che autorizza l'invio
End With
'On Error Resume Next 'con questo comando anche in caso di errore va avanti
On Error GoTo ERRORE
Cells(i, 15) = "INVIATA"
Set OutMail = Nothing
Set OutApp = Nothing
Application.SendKeys "%I"
Next i
ERRORE:
Cells(i, 16) = "ERRORE, NON INVIATA"
Application.ScreenUpdating = True
End Sub
|
Sub inviamail()
Application.ScreenUpdating = False
Dim OutApp As Object
Dim EmailAddr As String
Dim subj As String
Dim BodyText As String
Foglio1.Select
Range("I2:I6500").Activate
Range("I2:I6500").NumberFormat = "#.##0,00"
Range("J2:J6500").NumberFormat = "mmmm/yyyy"
Range("O:P").ClearContents
rr = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To rr
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.Createitem(0)
'On Error Resume Next
With OutMail
.To = Cells(i, 2)
.cc = Cells(i, 3)
.bcc = ""
.Subject = Cells(i, 4)
.body = "aaaa"
'Cells(I, 5) & Trim(Cells(I, 8)) & " " & "ZZZZZZZZ:"
.attachments.Add (Cells(i, 6) & Cells(i, 7))
'.display questo comando visualizza la finestra del messaggio di outlook e in caso di
' invio di email multiple fa sfarfallare il monitor
.send
Application.SendKeys "%I" ' non fa uscire la finestra di Outlook che autorizza l'invio
End With
'On Error Resume Next 'con questo comando anche in caso di errore va avanti
On Error GoTo ERRORE
Cells(i, 15) = "INVIATA"
Set OutMail = Nothing
Set OutApp = Nothing
Application.SendKeys "%I"
Next i
ERRORE:
Cells(i, 16) = "ERRORE, NON INVIATA"
MsgBox ("La mail non è stata inviata alla seguente finanziaria :") & Cells(i, 11).Value
'If Cells(i, 16) = "ERRORE, NON INVIATA" Then
'MsgBox ("mail non inviata a:") & ActiveCell.Offset(0, -6).Value
'End If
Application.ScreenUpdating = True
Resume Next
MsgBox ("Invio multimail completato")
End Sub |
Sub elencoFile()
Dim percorso As String, tipo As String, fileDaTrovare As String, elenco As String
Dim elencoFile As String
percorso = "C:Documents and SettingsxxxxxDesktopOTTOBRE 2012" '<=== da cambiare ovviamente
tipo = "*.pdf"
fileDaTrovare = percorso & tipo ' qui potresti anche mettere il nome file con estensione
If Dir(fileDaTrovare) = "" Then
MsgBox "File: " & fileDaTrovare & " (non presenti)"
Exit Sub
End If
fileDaTrovare = Dir(percorso & tipo)
Do While fileDaTrovare <> ""
If fileDaTrovare <> "" Then
MsgBox ("Trovato " & fileDaTrovare)
End If
fileDaTrovare = Dir
Loop
MsgBox (fileDaTrovare)
End Sub |
