Webby
Beta Tester
YaBB God
    
Posts: 829

Some mistakes are too funny to make only once.

|
 |
Visual Basic for Applications anyone ?
« on: May 16, 2003, 07:09:19 PM » |
|
Who knows the solution for this :
I generate mailings through Excel, and let it send automatically with a Macro. So far so good, it works with the following code :
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 Wanbetaal_1_mail() Dim Email As String, Subj As String Dim Msg As String, URL As String Dim r As Integer, x As Double For r = 1 To 8 'data in rows 1-8 ' Get the email address Email = Cells(r, 2) ' Message subject Subj = "SalesPlaza"
' Compose the message Msg = "" Msg = Msg & Cells(r, 3) & "," & vbCrLf & vbCrLf Msg = Msg & "Bladiebladiebla," Msg = Msg & "Met vriendelijke groet," & vbCrLf & vbCrLf Msg = Msg & "M.v.Veelen" & vbCrLf Msg = Msg & "SalesPlaza" ' 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:05")) Application.SendKeys "%s" Next r End Sub
Now I want to add attachments (see the last column), what do I have to do to get it to work ?? I tried almost everything I think.....
|