Save and email with one button

J

jody frazier

I would like to have 1 button that would email the form and save it to the
same location when clicked. Right now I'm accomplishing this with using a
"email button" with the data connection attached to it to email my form and
then a "save button" to save the form to the same location. I would like to
combine the 2 if possible. Of course I don't have code for the email since
I'm using a data connection for that but here is my code to save the form to
the default location:

Sub CTRL2_9_OnClick(eventObj)
Dim txtPath
Dim txtName
Dim GMSRef

GMSRef = XDocument.DOM.selectSingleNode("my:myFields/my:JobNum").text
txtPath = "C:\My Documents\InfoPath Forms\"
txtName = ".xml"

XDocument.SaveAs(txtpath & GMSRef & txtName)

thisXDocument.Application.Close(true)
End Sub

Any ideas anyone?
 
S

S.Y.M. Wong-A-Ton

Have you already tried putting the rule to send the email on the Save button?
You can define both on the Save button; the only thing is that the rule will
run before the code, so the email sent before the save takes place.
 
J

jody frazier

No I haven't tried that yet. How do I go about doing that? I'm very new 2
InfoPath...
 
S

S.Y.M. Wong-A-Ton

Did you add the save button to the form yourself? Or are you using the save
button in the toolbar?

If you did the first, you can add a rule to the save button just like you
did for the email button. Double-click on the button, click on the Rules
button, and add a Rule with an Action that says: Submit using a data
connection. And use the email data connection you created.

If you used the latter, you'll have to add code to the code you've already
written (use an EmailAdapter for this; see
http://msdn2.microsoft.com/en-us/library/aa167746(office.11).aspx for an
example on how to do this).

From the code you provided previously it does not look like you're using the
save button in the toolbar, so the first method should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top