cjones_mcse
asked on
Open new Outlook message with email address and subject line complete but body blank
Basically I just need to know how to make the new Outlook message open. I know how to do the rest.
Here is the code I currently have:
Dim objOutlook As New Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strLtrContent As String
strLtrContent = "Dear " & FIRST_NAME.Value & " " & _
LAST_NAME.Value & ":" & vbCrLf & vbCrLf & _
"Your SITE account password is: " & Password.Value & _
vbCrLf & vbCrLf & "Please wait 24 hours before attempting to change your password." & _
vbCrLf & vbCrLf & "If you have questions or issues with MySite, please contact:" & _
vbCrLf & "John Doe (mailto:John.Doe@mysite.co m)" & vbCrLf & _
"Jack Doe(mailto:Jack.Doe@mysite .com) or" & vbCrLf & _
"Jane Doe (mailto:Jane.Doe@mysite.co m)" & vbCrLf
Set objEmail = objOutlook.CreateItem(olMa ilItem)
objEmail.Recipients.Add Email.Value
objEmail.Subject = "Your Account"
objEmail.Body = strLtrContent
objEmail.Send
So instead of sending this email, I just want it to fill in the recipient info (objEmail.Recipients.Add Email.Value) and the subject line (objEmail.Subject = "Your Account" and then open the message so I can write a personalized email. How do I modify this code to achieve this?
Here is the code I currently have:
Dim objOutlook As New Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strLtrContent As String
strLtrContent = "Dear " & FIRST_NAME.Value & " " & _
LAST_NAME.Value & ":" & vbCrLf & vbCrLf & _
"Your SITE account password is: " & Password.Value & _
vbCrLf & vbCrLf & "Please wait 24 hours before attempting to change your password." & _
vbCrLf & vbCrLf & "If you have questions or issues with MySite, please contact:" & _
vbCrLf & "John Doe (mailto:John.Doe@mysite.co
"Jack Doe(mailto:Jack.Doe@mysite
"Jane Doe (mailto:Jane.Doe@mysite.co
Set objEmail = objOutlook.CreateItem(olMa
objEmail.Recipients.Add Email.Value
objEmail.Subject = "Your Account"
objEmail.Body = strLtrContent
objEmail.Send
So instead of sending this email, I just want it to fill in the recipient info (objEmail.Recipients.Add Email.Value) and the subject line (objEmail.Subject = "Your Account" and then open the message so I can write a personalized email. How do I modify this code to achieve this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If outlook is your default mail client then I think you can do it by simply 'shell'ing the mailto:me@myhouse.com?subj ect=this%2 0is%20the% 20subject e.g.
Add the following declaration
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
then use
call ShellExecute(hwnd, "Open", "mailto:user@domain.com?su bject=This %20is%20th e%20subjec t", "", app.path, 1)
It should open a new email message with the default client and fill in the subject and to fields, obviously this is only useful to yourself if the default client is Outlook
Cheers
/Matt
Add the following declaration
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
then use
call ShellExecute(hwnd, "Open", "mailto:user@domain.com?su
It should open a new email message with the default client and fill in the subject and to fields, obviously this is only useful to yourself if the default client is Outlook
Cheers
/Matt
ASKER
Awesome Ed! Thanks a ton!
:)
Tacky, but works for me.