none
Photo to Calendar Note Field RRS feed

  • Question

  • In the past, we create the code lines inside the script of a contact form which puts the words from certain fields of the contact fields in the note field of the calendar event of that contact. And we had two different lines re the text areas and the date areas which are below. So what can I do to put a Photo of the Contact in the Note field? The Photo field is OlkContactPhoto1.

    Dim txtintrodate
    Dim txtintroperson

    if item.getinspector.modifiedformpages("General").controls("Intro Date").text <> "None" then txtintrodate = "Intro Date" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("Intro Date").text & vbcrlf
    if item.getinspector.modifiedformpages("General").controls("TextBox5").text <> "" then txtintroperson = "Intro Person" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("TextBox5").text & vbcrlf

    itmappt.body =txtintrodate & txtintroperson
    Saturday, April 19, 2014 8:57 PM

All replies

  • Hello Imseaz,

    The Body property of the AppointmentItem class accepts only a plain text. Instead, you need to use the RTFBody property which operates a Byte array that represents the body of the Microsoft Outlook item in Rich Text Format. In the RTF markup you can try to embed an image, see Programatically adding Images to RTF Document for more information.

    Saturday, April 19, 2014 9:22 PM
  • Thanks much. My background does not include how to figure this out. Can you maybe tell me what to put in the script as with other lines of this script it creates the calendar event for the opened contact and adds to the note field in the calendar event. Also, if i copy the picture I can paste it to the note field, so the note will show the photo I copied and pasted.
    Saturday, April 19, 2014 9:40 PM
  • Hello Imseaz,

    You just need to set the RTFBody property of the Appointment class. To compose the correct markup please see the following forum page which provides a sample code in C# - Programatically adding Images to RTF Document . You may find the .NET RTF Writer Library in C# helpful.

    Sunday, April 20, 2014 8:26 PM
  • Thanks. However I can't figure it out. Sorry. Does anyone have a moment to just post what i change?
    Monday, April 21, 2014 4:57 AM
  • Hi Imseaz,

    Base on the description, you want to insert a picture into the body of appointItem. As far as I know, we can get the picture in a image control using code below:

    Set Picture =Item.GetInspector.ModifiedFormPages("General") _
                .Controls("Image6").Picture 

    I want to save the picture into hard disk and then use code below to insert a picture into the body of item:

     Set aDoc = Item.GetInspector().Application.ActiveInspector.WordEditor
    
    aDoc.Shapes.AddPicture "C:\Users\UserName\Desktop\test2.bmp"
    

    But I failed to find a workable way to save the picture. I used the stdole.StdFunctions.SavePicture, but it doesn't work in VBScript.

    Then I want to copy the picture via copyboard, and past it using code below:

    Set aDoc = Item.GetInspector().Application.ActiveInspector.WordEditor

    aDoc.Application.Selection.Paste

    But I also failed to use the clipboard in VBScript.

    So I didn't find a workable way to insert a picture from contact form. As a workaround, I suggest you using VBA to achieve the goal like the two ways mentioned above.

    Hope it is helpful.

    Best regards

    Fei



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 21, 2014 1:16 PM
    Moderator
  • Fei,

    Appointment items use the RTF markup for their bodies. You will not find the HTMLBody property in the list of their properties. So, the Word editor will be useless in that case.  

    Monday, April 21, 2014 1:35 PM
  • So as to this line, do i just change it and put in the field name? So what do i change re this line? itmappt.body =txtintrodate & txtintroperson
    Monday, April 21, 2014 7:08 PM
  • You can try to use the RTFBody property. The Body accepts a plain text without formatting. Please see my previous messages for more information.
    Tuesday, April 22, 2014 7:30 AM
  • Tuesday, April 22, 2014 2:44 PM
  • Again, I hear what you say but don't know how to change it for the RTFBody position....can you show me please the details of what to do?  thanks
    Wednesday, April 23, 2014 2:32 AM
  • I'm not an RTF guru. But, I'd recommend taking a look at the RTF specification first.
    Wednesday, April 23, 2014 6:33 PM
  • I understand...but looking at that does not show me what to do....this just comes down to referring to this field of the photo and it comes to the note field like the others areas I do...Anybody else know how to do this please?

    Wednesday, April 23, 2014 10:08 PM
  • Hi Imseaz,

    I suggest you redesing the project using VSTO. You can create a custom form region, the custom form region offer many enhancements over traditional Outlook forms development:

    • Customize the default page of any standard form.
    • Add up to 12 extra pages to any standard form.
    • Replace or enhance any standard form.
    • Display custom UI in the Reading Pane and in Inspectors.

    Another benefit of Form Regions is that instead of writing your code in notepad and VBScript, form regions are designed to be driven with an add-in.  Thus, you can work in your favorite development environment and take advantage of all the features it provides. ( refer to Outlook form regions)

    You can get more detail about custom form region from link below:

    Creating Outlook Form Regions

    Outlook Form Regions Overview

    And links below may be also helpful:
    Outlook Solutions

    Welcome to the Outlook 2013 Primary Interop Assembly Reference

    Managed add-ins built with Visual Studio (VSTO)

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 24, 2014 2:12 AM
    Moderator
  • I don't understand this also......so you know, I can right click the photo in a contact, copy it, and then paste to the note field of the calendar....so the note field of the calendar takes a photo as normal...I just need the way to use a code to in my script to do it as my script does it for other fields....again, here is the code that works for other fields and since the note field of the calendar event takes a photo pasted, what do I change in this one:

    Dim txtintrodate
    Dim txtintroperson

    if item.getinspector.modifiedformpages("General").controls("Intro Date").text <> "None" then txtintrodate = "Intro Date" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("Intro Date").text & vbcrlf
    if item.getinspector.modifiedformpages("General").controls("TextBox5").text <> "" then txtintroperson = "Intro Person" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("TextBox5").text & vbcrlf

    itmappt.body =txtintrodate & txtintroperson

    Thursday, April 24, 2014 4:08 PM
  • Any thoughts? Have not heard back from anyone.
    Monday, April 28, 2014 5:21 AM
  • Please see all replies above.
    Monday, April 28, 2014 6:06 AM
  • The other areas do not solve this. I just want the way to put the contact photo in the calendar body fiield from my script that does it for the other fields to the calendar body. So what equals the photo field and how to add to the body line of the script which I showed to all?
    Tuesday, April 29, 2014 1:24 AM
  • Imseaz,

    Did you try to customize the RTF markup of the body?

    Tuesday, April 29, 2014 7:29 AM
  • It is not clear to me how to do that for the body field of an outlook calendar event. If can show me what to do, I wll try it.
    Wednesday, April 30, 2014 1:31 AM