• Launch e-mail with boilerplate message (2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Launch e-mail with boilerplate message (2003)

    Author
    Topic
    #446676

    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!

    Viewing 0 reply threads
    Author
    Replies
    • #1086783

      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

      • #1086811

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

        Private Sub cmdEmailThis_Click()

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

        End Sub

        • #1086829

          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]

          • #1086844

            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?

            • #1086846

              You can also add some body text, but a) there is a limit to the length of the mailto string, and 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.

            • #1086847

              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

    Viewing 0 reply threads
    Reply To: Launch e-mail with boilerplate message (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: