none
exchange 2007 web services api reading html emails without the tags RRS feed

  • Question

  • I am upgrading an application from vb6 that read emails using ms outlook.  it did not matter if the email was text of html.

    now I am using vb.net and exchange web services api and when I read a html email it if full of tags.  is there a way just to read the text that would be normally be displayed and ignore all the html tags and formatting?

    Friday, November 19, 2010 4:02 PM

Answers

  • Hello iePaul,

    If you are using the EWS Managed API, you will want to request the plain text of the body by setting the PropertySet.RequestBodyType property to "Text".

    PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties);
    properties.RequestedBodyType = BodyType.Text;
    Item item = Item.Bind(service, itemId, properties);
    

    With regards,

    Michael Mainer

    Microsoft Corporation


    Michael | Microsoft Exchange SDK
    Friday, November 19, 2010 7:01 PM
    Moderator

All replies

  • Hello iePaul,

    If you are using the EWS Managed API, you will want to request the plain text of the body by setting the PropertySet.RequestBodyType property to "Text".

    PropertySet properties = new PropertySet(BasePropertySet.FirstClassProperties);
    properties.RequestedBodyType = BodyType.Text;
    Item item = Item.Bind(service, itemId, properties);
    

    With regards,

    Michael Mainer

    Microsoft Corporation


    Michael | Microsoft Exchange SDK
    Friday, November 19, 2010 7:01 PM
    Moderator
  • Worked perfect thanks!
    Monday, November 22, 2010 11:10 AM
  • I am having the same issue i have a script but it is not clear where the propertyset.requestbodytype should be added.

    $MailboxName = "user@user.com"
    $StartDate = new-object System.DateTime(2009, 08, 01)
    $EndDate = new-object System.DateTime(2009, 11, 01)

    $dllpath = "D:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2)

    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind

    $service.AutodiscoverUrl($aceuser.mail.ToString())

    $folderid = new-object  Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxName)
    $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid)
    $cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,2000)
    $cvCalendarview.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview)
    foreach ($apApointment in $frCalendarResult.Items){
         $psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
         $apApointment.load($psPropset)
        "Appointment : " + $apApointment.Subject.ToString()
        "Start : " + $apApointment.Start.ToString()
        "End : " + $apApointment.End.ToString()
        "Organizer : " + $apApointment.Organizer.ToString()
        "Required Attendees :"
        foreach($attendee in $apApointment.RequiredAttendees){
      " " + $attendee.Address
     }
        "Optional Attendees :"
         foreach($attendee in $apApointment.OptionalAttendees){
      " " + $attendee.Address
         }
        "Resources :"
         foreach($attendee in $apApointment.Resources){
      " " + $attendee.Address
         }
        " "
    }

    Thursday, June 21, 2012 8:48 PM