none
outlook,Add a string to the body of AppointItem RRS feed

  • Question

  • Hello,

           I want to add a string to the body of appointItem. I used "putbody" before, But this method covered the former body of the appointItem.I want to keep the former body and add a string to the body. Thank you~

    Thursday, July 11, 2013 8:52 AM

Answers

  • What doesn't work?

    I just tried a test on an appointment item using some quickie Outlook VBA code. I opened the appointment and put some text and a hyperlink into the body of the appointment.

    I then ran this code, which ended up adding the new text to the body and preserved the original text and hyperlink:

    Sub ApptBody()
        Dim s As String
        Dim a As Outlook.AppointmentItem
       
        Set a = Application.ActiveInspector.CurrentItem
        s = a.Body
        s = s & vbCrLf & "this is a test"
        a.Body = s
        a.Save
    End Sub


    Ken Slovak MVP - Outlook

    • Marked as answer by Cappu893300 Wednesday, July 17, 2013 8:12 AM
    Monday, July 15, 2013 2:49 PM
    Moderator

All replies

  • Retrieve the current Body as a string and then use string functions to append your string to the current Body string. Then write it back and save the item.

    Ken Slovak MVP - Outlook

    Thursday, July 11, 2013 2:55 PM
    Moderator
  • Thank you very much~

    I get the editor of Appointment,and insert a string~

    If the body has a Hyperlink or a Form,your method doesn't work~

    Thank you all the same~

    Monday, July 15, 2013 9:08 AM
  • What doesn't work?

    I just tried a test on an appointment item using some quickie Outlook VBA code. I opened the appointment and put some text and a hyperlink into the body of the appointment.

    I then ran this code, which ended up adding the new text to the body and preserved the original text and hyperlink:

    Sub ApptBody()
        Dim s As String
        Dim a As Outlook.AppointmentItem
       
        Set a = Application.ActiveInspector.CurrentItem
        s = a.Body
        s = s & vbCrLf & "this is a test"
        a.Body = s
        a.Save
    End Sub


    Ken Slovak MVP - Outlook

    • Marked as answer by Cappu893300 Wednesday, July 17, 2013 8:12 AM
    Monday, July 15, 2013 2:49 PM
    Moderator