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.com)" & vbCrLf & _
                 "Jack Doe(mailto:Jack.Doe@mysite.com) or" & vbCrLf & _
                 "Jane Doe (mailto:Jane.Doe@mysite.com)" & vbCrLf

Set objEmail = objOutlook.CreateItem(olMailItem)
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?
LVL 10
cjones_mcseAsked:
Who is Participating?
 
edwardiiiCommented:
Hi, cjones_mcse.

I haven't tested your code above, but if it populates the body of an email and sends it, and you just want a new email to open so you can populate the body yourself and send it manually,
just REM out the last two lines of code:

     'objEmail.Body = strLtrContent
     'objEmail.Send

However, it is Friday evening, so maybe I entirely misunderstood your question.  In any event, here's the code I use.  The main thing I've noticed when manipulating Outlook 2000 is that it ignores all instances of "vbNewLine", so I have to do a replace with "<br>":

    Dim outApp As Outlook.Application
    Dim olMail As MailItem
    Set outApp = New Outlook.Application
    Set olMail = outApp.CreateItem(olMailItem)

    Dim strTemplate, strSubject As String
    Dim strTxtAllConvert As String
    strTxtAllConvert = Replace(txtAll.Text, vbNewLine, "<br>")
    strTemplate = strTxtAllConvert

     'required to control the HTML body font:
    Dim strFontControlBody As String
    strFontControlBody = "<font face = MS Sans Serif size=3>" & strTemplate & "</font>"
   
    strSubject = "%& MDN: " & strMDN & "*" & strCenter & "**" & strRep & "***" & strProblemType

   
    With olMail
        .To = "WATSSRemedy-coordinators@nw.verizonwireless.com"
        .Subject = strSubject
         .HTMLBody = strFontControlBody
        'Line above invokes HTML control of email font; so line below no longer required
        '.Body = strTemplate
        '.Attachments.Add _
        'source:="C:\Documents and Settings\edwardiii\Images\VZW.jpg"
        .Display
    End With


0
 
DrDamnitCommented:
What version of Outlook do you have? Some of the later versions don't quite work properly. I have 2003, and ended up copying the address to the clipboard so that when the message displayed, all I have to do is paste it in.

Tacky, but works for me.
0
 
ShelfieldCollegeCommented:
If outlook is your default mail client then I think you can do it by simply 'shell'ing the mailto:me@myhouse.com?subject=this%20is%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?subject=This%20is%20the%20subject", "", 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
0
 
cjones_mcseAuthor Commented:
Awesome Ed!  Thanks a ton!
0
 
edwardiiiCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.