Submit current view via email for InfoPath 2003 users - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Submit current view via email for InfoPath 2003 users

Last post 11-24-2011 07:55 PM by Nhhome. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 04-06-2009 04:51 PM

    Submit current view via email for InfoPath 2003 users

    For some time now, I have been on the hunt for a solution to allow InfoPath 2003 users to submit the current view (not the default view) of a form via email (Outlook) without it sending as an attachment.  From what I am learning, there is a certain script or code that I can apply to the submit button (command) that will send the current view of the form in the body of the email.  I really don't know a thing about VB Script besides basic Excel stuff.  The code that others have posted is great and all, but I need to go back a step or two to actually walk through the steps of where to post the script or code. And if I need to change it to fit my application at all.

    I have enabled Microsoft Visual Studio Tools for Application (MVSTA) in InfoPath (I am working in InfoPath 2007).  

    In design mode/view, when I click on "Edit Form Code" in Button Properties window of the submit button, it opens MVSTA and notes "Write your code here." under the "Public Sub FormEvents_Submit(ByVal sender As Object, ByVal e As SubmitEventArgs)" section.  Is this where I would type in (or paste) the code?

    In addition to learning where to post the script, I need the specific script information that will make this work.  Preferably, I would like to copy what someone gives me and paste it in whatever area it goes and then close the window.  If there is anything else needed, I need specific instructions of what to alter or further customize.

     If it helps, here is my application:

    My company has not transitioned everyone to MS Office 2007 yet, which means even though I build 2003 forms using InfoPath 2007, the users will be submitting the forms via 2003.  The forms that I'm creating have different views because each view is sent to a different group of people.  I can adjust the Email Submit data connection settings to "Send only the active view of the form and no attachment," but that results in a blank email sent from 2003 users.  The moment I change the setting so that 2003 users can submit it as an attachment, they lose the ability to send the current view (meaning the view that is sent/attached is the default view of the form).  I have a couple of different forms and different applications, and my problem stems from needing to be able to have 2003 users submit a form that captures the current view and sends it in the body of the email instead of as an attachment. 

     In a perfect world, I would tell everyone to catch up and update their programs to Office 2007!  Only I haven't the ability or authority to do so.  I'm so close, and everything else in InfoPath has been within my reach (having little technical experience), but I need help going the rest of the way.  I know it's possible.

     Thanks in advance for any help or assistance!

  • 05-18-2009 11:01 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

    Hello,

    I implemented this just yesterday, but in JScript. You may want try out the 'MailEnvelope' object. I do not know if it is available through VBScript or not. Just in case it helps or gives you a new direction, I would be more than happy.

    var oEnvelope = Application.ActiveWindow.MailEnvelope;

    oEnvelope.Subject = "hello";

    oEnvelope.To = email@gmail.com;

    oEnvelope.Visible = true;

    love-n-peace,

    ~shaan

  • 05-31-2011 12:08 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

     

    Hi i am fairly new here... and couldn't get this to work. Could you please help me show how to do this step-by-step? Thanks, Kaushik
  • 05-31-2011 04:35 AM In reply to

    • GazM
    • Top 200 Contributor
      Male
    • Joined on 11-09-2005
    • England
    • Posts 54

    Re: Submit current view via email for InfoPath 2003 users

    Hi

    Try this VBScript. It works with my Infopath 2003 forms. The form is attached to the email as well as displaying in the body of the email.

    Sub btnSend_OnClick(eventObj)

    Dim myEnvelope

    set myEnvelope = Application.ActiveWindow.MailEnvelope

    ' Specify addresses, subject, and introduction.

    myEnvelope.To = someone@example.com

    'myEnvelope.CC = someone@example.com

    'myEnvelope.BCC = someone@example.com

    myEnvelope.Subject = "subject text here"

    'myEnvelope.Introduction = "text here if required"

    ' Include form template with form.

    myEnvelope.EmailAttachmentType = EmailAttachmentType.XmlXsn

    ' Display form with e-mail envelope.

    myEnvelope.Visible = True

    End Sub

     

    Gary

  • 05-31-2011 05:00 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

    Thanks Gary for your response...

    But i can see that am using JScript for my form, could you help me with the same code in JS? And would it be possible to have TO and CC fields be picked up from the form?

    Your help is much appreciated.

    Thanks,

    Kaushik

  • 05-31-2011 05:11 AM In reply to

    • GazM
    • Top 200 Contributor
      Male
    • Joined on 11-09-2005
    • England
    • Posts 54

    Re: Submit current view via email for InfoPath 2003 users

    Kaushik

    Sorry but I don't know how to do this in JScript. The code in the previous replies should be enough, with the addition of

    oEnvelope.CC

    It is simple enough to create a variable to extract the value of the TO and CC fields from a textbox in your form. A search of the site will bring up plenty of examples.

    Gary

  • 05-31-2011 06:24 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

     

    Gary, Thanks for your help so far, just wanted to understand another thing for now - is there a post / example around using IF statements in InfoPath 2003?

    Thanks,

    Kaushik

  • 05-31-2011 06:40 AM In reply to

    • GazM
    • Top 200 Contributor
      Male
    • Joined on 11-09-2005
    • England
    • Posts 54

    Re: Submit current view via email for InfoPath 2003 users

    Kaushik

    Just search the site for "IF statement"

    It can be done using code or using Rules and Conditional Formatting.

    Gary

  • 05-31-2011 07:05 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

    Gary,

    Thanks for your response, I shall search the site and hope to find something....

    Regards,

    Kaushik

  • 09-23-2011 09:30 AM In reply to

    Re: Submit current view via email for InfoPath 2003 users

    Can you please share how you did this using JScript?

    Filed under: ,
  • 11-24-2011 07:55 PM In reply to

    • Nhhome
    • Not Ranked
    • Joined on 11-24-2011
    • Posts 1

    Re: Submit current view via email for InfoPath 2003 users

     I saw this in other tread http://www.infopathdev.com/forums/t/5780.aspx

     It is working like charm!!!!!

     

    function OpenMailEnvelop(subject, to)

    {
        try
        {
      var oEnvelope = Application.ActiveWindow.MailEnvelope;
     
      oEnvelope.Subject = subject;
      oEnvelope.To = to;
      oEnvelope.Visible = true;
     
            return true;
        }
        catch(exception)
        {
            return false;
        }
    }
    function btnSomeButton::OnClick(eventObj)
    {
      OpenMailEnvelop("this is the subject", "someone@somewhere.com")
    }

     

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