Form in Email Body - InfoPath Dev
in

InfoPath Dev

Form in Email Body

Last post 08-17-2005 05:52 PM by Patrick Halstead. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 08-12-2005 01:34 PM

    Form in Email Body

    I have created a form with a button that e-mails the form as an attachment. How do I get it to send the form in the body of the email instead? I've gone through previous topics and found this JScript code:

    var oEmail = XDocument.DataAdapters("Email Submit");<BR>oEmail.To = "<A
    href="mailto:[email protected]">[email protected]</A>";<BR>oEmail.CC = "<A
    href="mailto:[email protected]">[email protected]</A>";<BR>oEmail.Subject =
    "subject"<BR>oEmail.Intro = XDocument.Dom.xml;<BR>oEmail.Submit();<BR>

    But it doesn't seem to work. I get a syntax error. Please help. I am new to Infopath and have very little programming knowledge.

  • 08-13-2005 12:47 AM In reply to

    Hi Khansolo,
    I guess you have copied the code directly from IE and pasted in the script. If you look at it has all <br> tags and href tags.

    First copy the code into notepad and again copy it from notepad and place it in the script, doing this will remove the html tags from the code.

    Hope this Helps!

    Agni
    InfoPath Dev India
  • 08-15-2005 07:25 AM In reply to

    Hi Agni,

    Thanks for pointing out the html tags for me. The code seems to be working but how do I get it to send the e-mail with the same settings as my data connection? I have it set so that it is sent to the e-mail address that is entered in the field of the form. I also have the subject bound to a specific field on the form as well. Also, when I click submit, it sends 2 e-mails: One from my data connections setting and one from this code. How do I get it to just send one? There's another problem. When I send it via the code, the e-mail contains this in the body:

    <?xml version="1.0"?><?mso-infoPathSolution productVersion="11.0.6357" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\khan\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer\9e44ab8135f54e24\manifest.xsf" solutionVersion="1.0.0.5" initialView="Data Entry" ?><?mso-application progid="InfoPath.Document"?><dfs:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-08-11T20:46:44" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us" xmlns:xdado="http://schemas.microsoft.com/office/infopath/2003/adomapping" xdado:dataModified="">

    <dfs:queryFields>
    <q:Table1 ID="" Date="" Requested_By="" Location="" Request_Type="" Contact="" Format="" Standard="" Language="" Special_Instructions="" Request_Closed_="" Comments=""></q:Table1>

    </dfs:queryFields>
    <dfs:dataFields>
    <d:Table1 ID="" Date="" Requested_By="" Location="" Request_Type="Tape Retrieval" Contact="" Format="" Standard="" Language="" Special_Instructions="" Request_Closed_="" Comments=""></d:Table1>

    </dfs:dataFields>
    <my:Email>[email protected]</my:Email>
    </dfs:myFields>

    How do I get it to send the form as is on Infopath?


  • 08-15-2005 10:46 AM In reply to

    I have already figured out a solution for questions 1 & 2. But I'm still having problems with question 3. How do I email an embedded form (that is already filled out with data) in the body of the email? The code e-mails the form in text format and not in HTML.
  • 08-15-2005 11:09 AM In reply to

    Hi Khansolo,

    Default send functionality is to send the form as MHT in the e-mail body. Using custom code you may be missing that.

    One other thing you could look at is the Export method:
    XDocument.View.Export("C:\\MyView", "MHT");

    This requires full trust but you might be able to use it.

    My guess is that you want default send functionality.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-15-2005 12:03 PM In reply to

    Hi Patrick,

    Yes, I would like default send functionality. Is there any way to do this without full trust?
  • 08-15-2005 02:51 PM In reply to

    Hi Khansolo,
    Default "File->Send To E-mail Recipient" is fine even for "Restricted" forms. Unfortunately, it doesn't support programmatically modifying who you send it too. This is a great question - you want to have it send the form as HTML but control the routing via the envelope parameters. Let me as Microsoft and see what they say ...

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-15-2005 03:39 PM In reply to

    Hi again,
    OK, I just confirmed with MS that this functionality is not part of the e-mail submit data connection in InfoPath SP1. Apparently, this feature was cut because it was too difficult to get the security rights and satisfy the testing matrix for sending HTML in the data connection during the tight SP1 dev cycle. Obviously, more information than you cared to know...

    Bottom line: can't do it.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-16-2005 06:32 AM In reply to

    Hi Patrick,

    Can I use the downlevel tool to do this? I'm not too sure how to go about in using this tool but I read somewhere that this might help.

  • 08-16-2005 11:47 AM In reply to

    Hi again Khansolo,

    The downlevel tool that we provide displays InfoPath forms in HTML so that people with a browser can see them. This is not the same as your e-mail scenario, although I suppose you could put a link to the form in e-mail and have them navigate to that. I suspect this isn't quite the scenario you had in mind.

    If you absolutely need to provide this feature in e-mail, my recommendation would be to investigate one of two things. First, you can Export the form as MHT, but you will need to make it Full Trust first. Use Regform /T for that (see other posts on regform for info). Regform creates an MSI form that you can then send to people for installation. The main downside is you don't get "auto-upgrade" when you change the form template. You have to send them a new MSI. You could also use a digital certificate to make the form full trust, but then they have to install the digital certificate. Anyway, the idea is to use the Export feature (which is level 3 security only - that's why you need to do full trust) to export the form as MHT. You'll add an OnSubmit handler which exports the form as MHT, and then loads the HTML dom from the exported MHT file and adds it to the body of your e-mail message before sending the e-mail. This will provide the support you need and shouldn't be too tricky.

    The other option, which may not be as good is to use the image from a signed form and attach that to the e-mail. This will also require full trust to auto-sign the form and extract the image. The downside of this approach is that the image won't show up as well in the message body (it will likely be an attachment). However, this is slightly better than the above approach since the image is full-fidelity whereas MHT isn't quite (buttons are stripped, etc.). Maybe you don't want full-fidelity, though.

    If you need help with either approach, let us know.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-17-2005 06:54 AM In reply to

    Hi Patrick,

    I actually wouldn't mind using the downlevel tool since my goal is for the e-mail recipient to only read the form that has already been filled out. My problem is I don't know how to use the downlevel tool. I know you have to use a JScript code but I don't konw where to put the code.

    Karen
  • 08-17-2005 05:52 PM In reply to

    Hi Karen! :)
    So, two options:
    1) Use the downlevel tool that ships with the SDK
    - Pros: costs $0 and works for most stuff
    - Cons: requires nontrivial setup on a server, slow, only supports default view, not everything works (for example, hyperlinks in rich text controls), need Internet Explorer, separate setup required for each form, etc.

    Steps:
    1. Download SDK (link in right pane:http://www.infopathdev.com/cgi-bin/awredir.pl?url=http://www.microsoft.com/downloads/details.aspx?familyid=351f0616-93aa-4fe8-9238-d702f1bfbab4&displaylang=en)
    2. Open help file that comes with SDK
    3. Click on Search tab
    4. Enter "Using the Downlevel Tool" and click List Topics
    5. Click on the item returned
    6. Read the documentation
    7. Setup server process to run tool on demand

    2) Use another downlevel tool that someone else provides (for example, our Forms Viewer download). I will assume Forms Viewer for following analysis:

    - Pros: more support, faster rendering, simpler setup, multiple views, support for other browsers, works with all forms published to server
    - Cons: non-eval version is not free, no support for business logic, etc.

    1. Navigate tohttp://www.infopathdev.com/downloads/free/default.aspx?i=0b8a2bea00d34ed2be2ac16fdd9232bd
    2. Download the zip file by clicking on the title
    3. Install the viewer on your server (see installation instructions)
    4. Publish an InfoPath form template to your server
    5. Fill out a form for the template andsave to your server (SharePoint ok)
    6. From a machine not running InfoPath, click on the XML file.
    Result: you should see it render in the "downlevel" view.
    Note: setting up a link to use for people who have InfoPath installed is easy to do in SharePoint (calculated column). For a non-SharePoint server, you will have to do a little more.

    Hope this helps.


    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.