A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq
Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Saturday, September 3, 2005

Sending email in InfoPath using third party component

You can send email in InfoPath using third party components. You must use InfoPath Toolkit. Toolkit is required to write managed code in InfoPath. To see how you can send email using System.Web.Mail namespace, read following post:

Sending Email From InfoPath Using Managed Code

I used ASPEmail component in my code, this component can be downloaded from the following link:

www.aspemail.com

After downloading the component, install it on your machine. Create an InfoPath form and add a button to it. Double click the button and select "Edit Form Code..." from the dialog box. This will open code editor (in Visual Studio). Add component in references. Right click "References" in solution explorer and add a reference to ASPEmail component (ASPEmailLib.dll).
Include namespace in your code: using ASPEMAILLIB;
Add following code click event of the button:

[InfoPathEventHandler(MatchPath="CTRL1_1", EventType=InfoPathEventType.OnClick)]
public void CTRL1_1_OnClick(DocActionEvent e)
{
ASPEMAILLib.IMailSender objMail;
objMail = new ASPEMAILLib.MailSender();
objMail.Host = "smtp.yourdomain.com";
objMail.From = "share.point@yourdomain.com";
objMail.AddAddress("user@sharepoint.com" , "John Doe");
objMail.Body = "This a test mail and currently logged in user is " + System.Environment.UserName;
objMail.Send("share.point@yourdomain.com");
}

You can send attachments as well. Add following line before the "send" statement:
objMail.AddAttachment(your file path);
To add CC address, use the following line:
objMail.AddCC("email address","user name");
To add BCC address, use the following line:
objMail.AddBcc("email address","user name");
To send HTML mail, set isHTML property to true:
objMail.IsHTML = true;
To send mail to a newsgroup:
objMail.SendToNewsgroup(string newsgroup);


-SSA

Sending email after submitting InfoPath form (without coding)

Q: I use InfoPath form to submit data to a database. My form is published in SharePoint. How can I send an email either to myself or to some one else right after submitting the form?


Why don't you use Infopath's built in functionality? You have created a data connection to submit data to database. Create another connection that will send an email to your account. In Tools > Submitting Forms > Rules, Add a new rule. Add action in this rule. Select "Submit using a data connection" in the actions drop down and select email connection in the "Data Connection" drop down.


--SSA