Page 2 of 2

Email using API [shell32.dll]

Posted: Wed Apr 18, 2012 12:25 pm
by Darren
Can somebody try this with Microsoft Outlook Email?

I have updated it!

Declare Email As "ShellExecuteA" Of "shell32.dll"
    hwnd As Long
    lpOperation As String
    lpFile As String
    lpParameters As String
    lpDirectory As String
    nShowCmd As Long
End declare

Dim EmailAddress As String

Dim Subject As String

Dim OutputString As string

EmailAddress = "d.j.smith@aim.com"

Subject = "Darrens Test"

OutputString = "Hello Darren," + Cr

OutputString = OutputString + "How are you?" + Cr

OutputString = OutputString + "" + Cr

OutputString = OutputString + "Hope that you are fine!" + Cr

OpenMailBox(EmailAddress, Subject, OutputString)

Sub OpenMailBox(Address As String, Subject As String, Body As String)
    Email.lpoperation = "open"
    Email.lpfile = "mailto:" + Address + "?subject=" + Subject + "&body=" + ReplaceSubStr$(OutputString, Chr$(13), "%0D%0A")
    Email.Execute

    Sleep 3000

    SendKeys ("%s")
End Sub

It automatically creates an email and then sends it.

Please let me know what happens!

Darren