PDA

View Full Version : Gestione allegato in Vba excel 2003


Thebaro
02-03-2011, 16:24
il codice:

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Dim r As Integer, x As Double
For r = 2 To 4 'data in rows 2-4
' Get the email address
Email = Cells(r, 2)

' Message subject
Subj = "Pulizia profilo"

' Compose the message
Msg = ""
Msg = Msg & "Ciao " & vbCrLf & vbCrLf
'Msg = Msg & "Ciao " & Cells(r, 1) & "," & vbCrLf & vbCrLf
Msg = Msg & "abbiamo verificato che il tuo profilo Windows ha superato la dimensione limite di "

Msg = Msg & Cells(r, 3).Text & "." & vbCrLf & vbCrLf
Msg = Msg & "Attualmente il tuo profilo ha una dimensione di " & Cells(r, 1) & "," & vbCrLf & vbCrLf
Msg = Msg & "Al fine di migliorare le performance della macchina e ridurre i tempi di login e logoff è necessario che venga riportata ai valori standard." & vbCrLf
Msg = Msg & "In allegato una breve procedura che descrive i passi da seguire." & vbCrLf
Msg = Msg & "Grazie per la collaborazione."

' Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")

' Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")

' Create the URL

URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg

' Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus

' Wait two seconds before sending keystrokes

Application.Wait (Now + TimeValue("0:00:04"))
Application.SendKeys "%s" (l'ho duplicata sotto perchè si incastrava..soluzioni ?)
Application.Wait (Now + TimeValue("0:00:04"))
Application.SendKeys "%s"
Next r
End Sub

----

fine come posso includere un allegato alla email prendendolo da un percorso?

attualmente invia le email da un elenco di persone...


Grazie

Thebaro
03-03-2011, 08:38
up

Thebaro
07-03-2011, 10:15
up

Thebaro
08-03-2011, 10:20
up

Thebaro
09-03-2011, 16:24
up