SharePoint 2007, Infopath Submit button creates form name and sends email, not - InfoPath Dev
in

InfoPath Dev

SharePoint 2007, Infopath Submit button creates form name and sends email, not

Last post 03-09-2011 08:37 AM by dms.WebDev. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-08-2011 03:04 PM

    SharePoint 2007, Infopath Submit button creates form name and sends email, not

    I am using InfoPath 2007 with SharePoint 2007.  I've created a submit button that reads the next List ID* from a SharePoint List and places it the "fileName" field and submits the form to a SharePoint form library.  It works great.  When I add C# code behind the same Submit button to send an email, the email does not send. When I place the  same code in another button, the email sends just fine.  So it seems I can't put rules and code on the same button??

    *I used Clayton Cobb's tutorial for autonumering fields: http://claytoncobb.wordpress.com/2009/06/15/auto-numbering-infopath-forms/

     I don't want the user to have to take an additional step to send an email to all interested parties.  I want the email that is sent to be transparent to the user. Also I don't want to use the buit-in email wizard because I don't want the user to have to deal with the message box window.  As it is they will have to click yes or no after they click submit button. Must I create a workflow to achieve this instead?

     Here's my email code:

    //Submit button

    try

    {

    SmtpClient client = new SmtpClient(@"server.domain ");  MailAddress from = new MailAddress("[email protected]", "Tommy Test");

    MailAddress to = new MailAddress("[email protected]", "Testing to Dtest");

    MailAddress to2 = new MailAddress("[email protected]", "Sally Test");

    MailAddress to3 = new MailAddress("[email protected]", "Tommy Test");

    MailAddress copy = new MailAddress("[email protected]", "Sally Test");

     

    System.Net.Mail.MailMessage eMailMsg = new System.Net.Mail.MailMessage();

    eMailMsg.Body = @"System user: " + System.Environment.UserName + " has entered a new *TEST* Incident Report. View it here: http://server ";

    eMailMsg.Subject = "InfoPath Test Email generated from code";

    eMailMsg.From = from;

    eMailMsg.To.Add(to);

    eMailMsg.To.Add(to2);

    eMailMsg.To.Add(to3);

    eMailMsg.CC.Add(copy);

    client.Send(eMailMsg);

    //MessageBox.Show("Your Email Message has been sent to " + to);

    //clean up

    eMailMsg.Dispose();

    }

    catch (ArgumentException exc)

    {

    MessageBox.Show(exc.Message, exc.Source);

    }

    catch (SmtpException ex)

    {

    MessageBox.Show(ex.ToString());

    }

     

     

  • 03-08-2011 04:28 PM In reply to

    Re: SharePoint 2007, Infopath Submit button creates form name and sends email, not

    Hi,

    You will need to use SharePoint workflow on that document library to send the emails so that the user doesn't need to click on the email dialog box to send it.  If you do it through InfoPath they will need to click on the send button, that is just how the email integration works as it sends from the users Outlook client.

    Configuring the SharePoint workflow should not be too hard.

    you could also look at our DBXL tool (that does InfoPath to SQL mapping for reporting).  It also have some auto email functionality built in that is very useful (http://www.qdabra.com/en/products/DBXL.aspx)

    Ted

  • 03-09-2011 08:37 AM In reply to

    Re: SharePoint 2007, Infopath Submit button creates form name and sends email, not

    My observation from testing is that if there is code behind a button to send an email there will be no dialog box that pops up later.  The user must click a button initially to initiate the email. If I use the data connection wizard to set up the email (no code behind) then a dialog box will result.

    My question is can I place code to send email in a button that also submits the form back to a sharePoint library? Can I use code and Rules on one button control?  Hence this will require adding Rules to the button, and code behind.  Is this an option?  My first attempt didn't recognize the code behind to send the email but recognizes the rules to submit the form.  I am trying to fire off two events with one click... 

     

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