Send Email On Sharepoint Web Part Programmatically


public static bool SendMail(string Subject, string Body, bool IsBodyHtml, string From, string To, string Cc, string Bcc)
	{
		bool mailSent = false;
		try
		{
			SmtpClient smtpClient = new SmtpClient();
			smtpClient.Host = "10.10.2.1";
			smtpClient.Port = 25;
			MailMessage mailMessage = new MailMessage(From, To, Subject, Body);
			if (!String.IsNullOrEmpty(Cc))
			{
				MailAddress CCAddress = new MailAddress(Cc);
				mailMessage.CC.Add(CCAddress);
			}
			if (!String.IsNullOrEmpty(Bcc))
			{
				MailAddress BCCAddress = new MailAddress(Bcc);
				mailMessage.Bcc.Add(BCCAddress);
			}
			mailMessage.IsBodyHtml = IsBodyHtml;
			smtpClient.Send(mailMessage);
			mailSent = true;
		}
		catch (Exception) { return mailSent; }
		return mailSent;
	}
}

sumber: Learning Sharepoint

About windupurnomo

I'm interested in programming. I am active with several programming such as Java, C #, C, JavaScript, HTML. I'm also develop desktop application (Java Swing), Mobile Application (Android), and Web programming (ASP MVC).
This entry was posted in Microsoft, Sharepoint and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s