InfoPath and Outlook Integration - Can't set Body correctly - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

InfoPath and Outlook Integration - Can't set Body correctly

Last post 07-30-2013 06:08 AM by Psichiboy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-24-2013 08:09 PM

    • Psichiboy
    • Not Ranked
      Male
    • Joined on 01-30-2008
    • Philadelphia, PA
    • Posts 11

    InfoPath and Outlook Integration - Can't set Body correctly

    I'm working with IP2010 (rich client) and I have a need to open Outlook prior to sending an email. I have a view that mimics a new email message like in Outlook and it has fields for To, CC, Subject and Body. My Body field is a rich text box that I'm populating based on an XML file (I have email templates that set what shows up in the body of the email message). I have the XML data connection populating correctly and I've written the code to open Outlook successfully and I can pass in the information from my view into the mail message. However, I cannot get the Body field to set correctly. My body field in the view contains multiple paragraphs, but when I send it to Outlook, it's removing the paragraph breaks so I'm left with one long paragraph. I've tried setting the field with the InnerXML and OuterXML and even Value. I've tried setting the Body in the email message as HTML and Rich Text, but neither are working. Here is my code that I'm working with: Dim myNamespace As String = NamespaceManager.LookupNamespace("my") Dim nav1 As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:LeaseFlow/my:EmailBody", NamespaceManager) Dim nav2 As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:LeaseFlow/my:EmailHeader", NamespaceManager) Dim emailmessage As String Dim taskname As String, SentTo As String, Subject As String, CC As String, BCC As String emailmessage = nav1.SelectSingleNode("my:emailbodyMessage", NamespaceManager).InnerXML SentTo = nav2.SelectSingleNode("my:emailheaderTo", NamespaceManager).Value Subject = nav2.SelectSingleNode("my:emailheaderSubject", NamespaceManager).Value CC = nav2.SelectSingleNode("my:emailtoCC", NamespaceManager).Value BCC = nav2.SelectSingleNode("my:emailtoBCC", NamespaceManager).Value Dim oApplication As Microsoft.Office.Interop.Outlook._Application = New Microsoft.Office.Interop.Outlook.Application Dim newMail As Microsoft.Office.Interop.Outlook.MailItem = oApplication.CreateItem(OlItemType.olMailItem) newMail.BodyFormat = OlBodyFormat.olFormatHTML newMail.To = SentTo newMail.Subject = Subject newMail.Body = emailmessage newMail.CC = CC newMail.BCC = BCC newMail.Display(False) -------------------------------------------------------------------- Can anyone help me out please? I'm seriously stuck. Thank you in advance! Chris
  • 07-27-2013 10:23 PM In reply to

    Re: InfoPath and Outlook Integration - Can't set Body correctly

    Hi Chris,

    Why not just create a view that is used for the email and sending that as part of the data connection? That option is available out of the box.

    You don't have to launch Outlook and try to automate the sending. Just do it using out-of-the-box features.

    Kindly,

    Patrick Halstead
    Project Manager at Qdabra
  • 07-27-2013 10:24 PM In reply to

    Re: InfoPath and Outlook Integration - Can't set Body correctly

    Hi Chris,

    Why not just create a view that is used for the email and sending that as part of the data connection? That option is available out of the box.

    You don't have to write code or launch Outlook and try to automate the sending. Just do it using out-of-the-box features.

    Kindly,

    Patrick Halstead
    Project Manager at Qdabra
  • 07-30-2013 06:08 AM In reply to

    • Psichiboy
    • Not Ranked
      Male
    • Joined on 01-30-2008
    • Philadelphia, PA
    • Posts 11

    Re: InfoPath and Outlook Integration - Can't set Body correctly

    Hi Patrick, Thanks for the reply. Yeah, it was set up that way previously, however they wanted the ability to attach files to the email as it was being sent. I actually ended up figuring it out! When using the mailitem, there's a property called HTMLBody. So when I did mailitem.HTMLBody = RichTextBox it created my email with perfect formatting. Thanks again, Chris
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.