Outlook interop assembly code in infopath form 2007 is not working with infopath 2010. - InfoPath Dev
in

InfoPath Dev

Outlook interop assembly code in infopath form 2007 is not working with infopath 2010.

Last post 11-21-2013 06:03 AM by leoffneym. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-20-2013 09:50 AM

    Outlook interop assembly code in infopath form 2007 is not working with infopath 2010.

    Hi Team,
    Please resolve the below issue as it was very urgent.
    My client having requirement open a outlook window once clicked button in infopath from 2007.
    I was resolved using below procedure and code.
    I have added Outlook interop reference to the infopath code project and coded like below.
    Interop assembly added path : C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Outlook.dll
    code :
    public string CreatePDF()
    { // Create HTML. try { XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
    XPathNavigator xnMyField = xnDoc.SelectSingleNode("/my:XXXXXXXXXXX/my:woDetails/my:XXXXXXXXName" , this.NamespaceManager);
    wordordername = xnMyField.Value;
    fileName = wordordername + ".pdf";
    filePath = Path.Combine(Path.GetTempPath(), fileName);
    this.CurrentView.Export(filePath, ExportFormat.Pdf);
    return filePath;
    }
    catch { return filePath; }
    }
    public void CTRL25_19_Clicked(object sender, ClickedEventArgs e)
    { Outlook.Application oApplication = new Outlook.Application();
    Outlook.MailItem newMail = (Outlook.MailItem)oApplication.CreateItem(Outlook.OlItemType.olMailItem);
    filePath = CreatePDF();
    XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
    XPathNavigator xnCPField = xnDoc.SelectSingleNode("/my:XXXXXXXXXXXXXX/my:XXXXXXx/my:XXXXXXXx", this.NamespaceManager);
    XPathNavigator xnMyField = xnDoc.SelectSingleNode("/my:XXXXXXXXXXXXXXXxx/my:XXXXXX/my:XXXXXX", this.NamespaceManager);
    newMail.To = xnCPField.Value;
    newMail.CC = xnMyField.Value;
    newMail.Subject = "Please approve ";
    newMail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
    newMail.HTMLBody = "Dear Customer

    Thanks ";
    newMail.Attachments.Add(filePath, Outlook.OlAttachmentType.olByValue, 1, "Form");
    newMail.Display(true);
    }
    Issue : Clients who are having infopath 2007 are working fine but who are having infopath 2010 getting error screenshot which is attached to post...
    Please resolve the issue asap.
    thanks, VR
  • 11-21-2013 06:03 AM In reply to

    Re: Outlook interop assembly code in infopath form 2007 is not working with infopath 2010.

    Can you add a try catch block so the the error is better defined.  I have an idea of what the problem may be, but the error it returns may provide more insight.

    In your public void CTRL25_19_Clicked function add the following:

    try{

    all code goes here

    }
    catch(Exception exception)
    {
    MessageBox.Show("Error " + exception.Message);
    }

    This should provide you with a popup that displays more information about the error.

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.