Solved

Format Body of Message using Visual Basic Editor

Posted on 2008-10-20
3
228 Views
Last Modified: 2012-06-27
I'm sure there is an easy way to accomplish this but I have yet been able to find any.  I wrote some code (with the help of some of you experts) in visual basic editor to have an email automatically sent every x number of days.  The problem I am having is with the body of the message.  The entire message is one paragraph and doesn't look professional.  I would like to break it up with a salutation, several paragraphs, and a signature.  Please let me know what I need to to, thank you!
Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
    Dim olkMsg As Outlook.MailItem
    'Is the reminder for a task
    If ReminderObject.Item.Class = olTask Then
        Set objItem = ReminderObject.Item
        'Change "Send Message" on the following line to the subject you used for your task.  The name must be an exact match.
        If objItem.Subject = "Reminder:  Please go to emsCharts to electronically sign your Medical Command charts" Then
            Set olkMsg = Application.CreateItem(olMailItem)
                With olkMsg
                    Dim OlkRecip As Outlook.Recipient
                    Set OlkRecip = .Recipients.Add("recipient#1@xyz.com")
                                        OlkRecip.Type = olTo
                    olkMsg.Subject = "Reminder:  Please go to emsCharts to electronically sign your Medical Command charts"
                    olkMsg.Body = "To All EM Physicians:" & "I am sending this email to serve as a reminder for you to please sign your EMS Medical Command PCRs." & "The website is www.emscharts.com.  Enter your username and password.  Select Patient Records.  Select MD Consults.  A list of PCRs in which you need to sign will populate the screen.  Click on a chart to open it.  Scroll down to the bottom.  Select either Sign or Reject the chart.  Electronically sign your chart by entering your Social Security Number (or 9 digit number which you entered in your User Section instead of your SSN) and your password (same password you used to login).  Chart will close and return you to the list.  Select the next chart and follow steps 5 thru 7.  If you select Sign Chart within 2 minutes after signing your last chart you will not be required to perform step 7 (entering your SSN and Password).  Please let me know if you have any issues." & "Thank you and have a great day!!!" & "Anthony"
                    olkMsg.Send
                End With
            'Reset the reminder to some point in the future.  This code sets the next run to one day into the future.
            objItem.ReminderTime = DateAdd("d", 1, Now)
            objItem.Save
        End If
    End If
    Set objTaskItem = Nothing
End Sub
 
Private Sub Application_Quit()
    Set objReminders = Nothing
End Sub
 
Private Sub Application_Startup()
    Set objReminders = Application.Reminders
End Sub

Open in new window

0
Comment
Question by:medic2069
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 22758149
To break up the main part you need to identify break points but for instance see the below.

Chris
Dim msgBody As String
 
    msgBody = "To All EM Physicians:" & vbCrLf & vbCrLf & _
        "I am sending this email to serve as a reminder for you to please sign your EMS Medical Command PCRs." & "The website is www.emscharts.com.  Enter your username and password.  Select Patient Records.  Select MD Consults.  A list of PCRs in which you need to sign will populate the screen.  Click on a chart to open it.  Scroll down to the bottom.  Select either Sign or Reject the chart.  Electronically sign your chart by entering your Social Security Number (or 9 digit number which you entered in your User Section instead of your SSN) and your password (same password you used to login).  Chart will close and return you to the list.  Select the next chart and follow steps 5 thru 7.  If you select Sign Chart within 2 minutes after signing your last chart you will not be required to perform step 7 (entering your SSN and Password).  Please let me know if you have any issues." & vbCrLf & vbCrLf & _
        "Thank you and have a great day!!!" & "Anthony"
        Debug.Print msgBody
    
'    olkMsg.Body = msgBody

Open in new window

0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 125 total points
ID: 22758255
Adding a little more layout try:

Chris
Dim msgBody As String
 
    msgBody = "To All EM Physicians:" & vbCrLf & vbCrLf & _
        "I am sending this email to serve as a reminder for you to please sign your EMS Medical Command PCRs." & "The website is www.emscharts.com." & vbCrLf & _
        vbTab & "Enter your username and password." & vbCrLf & _
        vbTab & "Select Patient Records." & vbCrLf & _
        vbTab & "Select MD Consults." & vbCrLf & vbCrLf & _
        "A list of PCRs in which you need to sign will populate the screen." & vbCrLf & _
        vbTab & "Click on a chart to open it." & vbCrLf & _
        vbTab & "Scroll down to the bottom." & vbCrLf & _
        vbTab & "Select either Sign or Reject the chart." & vbCrLf & vbCrLf & _
        "Electronically sign your chart by entering your Social Security Number (or 9 digit number which you entered in your User Section instead of your SSN) and your password (same password you used to login)." & vbCrLf & vbCrLf & _
        "Chart will close and return you to the list.  Select the next chart and follow steps 5 thru 7.  If you select Sign Chart within 2 minutes after signing your last chart you will not be required to perform step 7 (entering your SSN and Password)." & vbCrLf & vbCrLf & _
        "Please let me know if you have any issues." & vbCrLf & _
        "Thank you and have a great day!!!" & vbCrLf & vbCrLf & "Anthony"
 
    olkMsg.Body = msgBody

Open in new window

0
 

Author Closing Comment

by:medic2069
ID: 31507824
Thanks.  Sorry for the delay.
0

Featured Post

SendBlaster Pro 4 - Bulk Email Sending Software

SendBlaster 4 Pro - Best Bulk Emailing Sending Software
Automatic Subscribe / Unsubscribe Processing
Great for Newsletters & Mass Mailings
Optional HTML & Text Composition
Integration with Google Features
Built in Spam Score Checking
Free Professional Templates - Feature Packed!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question