Email Attachment help please - InfoPath Dev
in

InfoPath Dev

Email Attachment help please

Last post 07-17-2010 05:58 AM by Skarn. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-15-2007 10:05 AM

    Email Attachment help please

    First off, thanks for a great site!! I've been lurking and gleaning info for quite some time.


    I an using the included code to make a new Outlook message appear. The reason I am doing it this way instead of with a data connection is because the person completing the form will need to edit the resulting email before it's sent. The Email code works fine for 1 part of the submission process except the attachment name. At a later stage, however, I need to get this email to be sent with no attachment at all.

    so the 2 questions are...

    1) Is there any way to change the attachment name from "Form1.xml" to something dynamic based on form fields using the code I've included (or some other coding)?

    2) Is there any way to get the same new, pre-filled email message to open except with no attachment at all?

    thanks in advance,
    Craig




    Function msoxd_my_editable_OnAfterChange(eventObj)

    ' If the submit operation is successful, set
    ' eventObj.ReturnStatus = True

    'Opens an email window with prefilled subject line and with form as xml attachment (no HTML version).
    On Error Resume Next

    Set oTo = XDocument.DOM.selectSingleNode("//my:myFields/my:StoredValues/my:MailSettings/my:to")
    Set oCC = XDocument.DOM.selectSingleNode("//my:myFields/my:StoredValues/my:MailSettings/my:cc")
    Set oBCC = XDocument.DOM.selectSingleNode("//my:myFields/my:StoredValues/my:MailSettings/my:bcc")
    Set oSubject = XDocument.DOM.selectSingleNode("//my:myFields/my:StoredValues/my:MailSettings/my:subject")
    Set oBody = XDocument.DOM.selectSingleNode("//my:myFields/my:StoredValues/my:MailSettings/my:body")

    formTo = oTo.text
    formCC = oCC.text
    formBCC = oBCC.text
    formSubj = oSubject.text
    formBody = oBody.text


    XDocument.UI.ShowMailItem formTo, formCC, formBCC, formSubj, formBody
    eventObj.ReturnStatus = False
    Exit Function
    End Function
  • 02-15-2007 11:13 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Email Attachment help please

    Hi Trunzoc,

    Check out this link,

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=3339
  • 02-22-2007 11:47 AM In reply to

    Re: Email Attachment help please

    Unfortunately, that thread doesn't answer either question.

    Any other suggestions?

  • 02-22-2007 12:12 PM In reply to

    Re: Email Attachment help please

    Hi Trunzoc and welcome to our forum!

    To answer your questions:

    1. Yes, you can do this. Use the e-mail adapter and AttachmentFileName. Here's an example:
    objEmailAdapter.AttachmentFileName = strName + "–" + strDate + ".xml";
    BTW: this is documented in the InfoPath 2003 SDK, a great reference if you haven't downloaded it yet.

    2. To remove the attachment, just make the above string blank.

    Happy Trails!

    Patrick Halstead
    Project Manager at Qdabra
  • 07-13-2010 12:02 AM In reply to

    Re: Email Attachment help please

    Hi Patrick, i'm trying to send an excel file as attachment but i'm unable to set "AttachmentFileName" to my file's path. it says it is read only.

    i'm using infopath 2007.

     please help. Urgent!!

  • 07-17-2010 05:58 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Re: Email Attachment help please

    Only speaking from Infopath 2003 point of view - but you could try just having an attachment field and let the infopath form itself be the attachment and use a normal email data adapter/secondary connection.

     If you need a code solution - in order to set the Outlook mail object's attachment property you may have to create a proper Outlook application object reference. I don't think the default Infopath code model allows you to reference and attach other files using the 'SendMail' function.

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