Hi there. I found the following code in file sent to me for another reason. I am wondering why this works.
This creates an Outlook message with the named fields completed. I have adjusted the text a little...my address is not fumei@BlahBlah.net
But it works. Outlook is NOT open. I do not have Outlook loaded. Yet this creates a process of Outlook.exe and the message. Just the message. The main Outlook application does not appear. Only the message.
Could someone explain how this is working to me? Hitting Send does indeed send the message. Why have I been creating instances of Outlook (and MAPI object, MailItem object...yadda yadda yadda), if this makes messages so simply?
What is going on here?
Gerry
My paintings and sculpture
Code:
'Used for creating an e-mail
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 MakeMessage()
Dim sText As String, _
sSubject As String, _
sBody As String, _
sWhoTo As String
sWhoTo = "fumei@BlahBlah.net"
sSubject = "Subject line text"
sBody = "Body text. Body text."
sText = "mailto: " & sWhoTo & "?Subject=" & _
sSubject & "&Body=" & sBody
'Send e-mail
Call ShellExecute(0&, "open", sText, vbNullString, vbNullString, -1)
End Sub
But it works. Outlook is NOT open. I do not have Outlook loaded. Yet this creates a process of Outlook.exe and the message. Just the message. The main Outlook application does not appear. Only the message.
Could someone explain how this is working to me? Hitting Send does indeed send the message. Why have I been creating instances of Outlook (and MAPI object, MailItem object...yadda yadda yadda), if this makes messages so simply?
What is going on here?
Gerry
My paintings and sculpture