Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Launch e-mail with boilerplate message (2003)

    My database has a form that displays information about members of an on-line forum. When I add a new member, I click a command button that launches an Outlook e-mail message addressed to the current record (the member whose name displays on the form). There's nothing else in the message--just the e-dress. I'm thinking there must be a way, via VBA, to cause the new message to open with a standard "subject:" (e.g., Welcome to the forum!) and some boilerplate text in the message body. Can anyone suggest where to start. Thanks!

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Launch e-mail with boilerplate message (2003)

    Does your current code use Docmd.Sendobject to create the email or Outlook automation?

    In either case you can specify the Subject and Body of the message in code, but the exact code would be a little different.

    If you had two string variables strSubject and strMessage which held the text you wanted to use, this is the code using Docmd.sendObject

    DoCmd.SendObject acSendNoObject, , , strTo, , , strSubject, strMessage, True

    With Outlook automation you will still use two string variables, but then have something like:

    With oMailItem
    .To = strTo
    .Subject = strSubject
    .Body = strMessage
    .Display
    End With
    Regards
    John



  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Launch e-mail with boilerplate message (2003)

    I'm not sure how to answer. My code reads thusly:

    <font face="Georgia">Private Sub cmdEmailThis_Click()

    Dim strEmailAddress As String
    strEmailAddress = "mailto:" & Me![MemberEmail]
    Application.FollowHyperlink strEmailAddress, , True

    End Sub</font face=georgia>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Launch e-mail with boilerplate message (2003)

    Change the line

    strEmailAddress = "mailto:" & Me![MemberEmail]

    to

    strEmailAddress = "mailto:" & Me![MemberEmail] & "?subject=Hello World"

    (You should, of course, substitute the appropriate subject). Instead of a fixed subject, you can also use an expression:

    Change the line

    strEmailAddress = "mailto:" & Me![MemberEmail]

    to

    strEmailAddress = "mailto:" & Me![MemberEmail] & "?subject=" & Me![SubjectText]

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Launch e-mail with boilerplate message (2003)

    Thank you, Hans! That's pretty straightforward. I suppose the matter of boilerplate text in the message body is another matter. Can you suggest an approach or recommend a source or an example?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Launch e-mail with boilerplate message (2003)

    You can also add some body text, but a) there is a limit to the length of the mailto string, and [img]/forums/images/smilies/cool.gif[/img] you can't enter line breaks.

    Example:

    strEmailAddress = "mailto:" & Me![MemberEmail] & "?subject=Hello World&body=Welcome to our forum."

    If you want to set a body text with line breaks, consider using DoCmd.SendObject.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Launch e-mail with boilerplate message (2003)

    Lucas

    You could create a table to contain the boilerplate text with a line number field in it, and then read it using a loop into a string variable. I have done this before, and used asterisks to bracket variables, e.g. *username*. Once the string has been created, you then use the Replace function to substitute the actual variables for the *...* text.

    HTH

    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •