General Bloging

Development and Stuff

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sending emails via Sharepoint 2007 code

if you are developing a webpart or any sharepoint customized feature,and you would like to send an email through your webpart or custom code,you can achieve this by 2 ways:

1) use normal .net classes to send email (System.Net.Mail namespace).
2) use below code:

using Microsoft.SharePoint.Utilities;

SPUtility.SendEmail(SPContext.Current.Web, false, false,
"to-address@mail.com", "E-mail title",
"E-mail body");

this code will use the configuration of your sharepoint installation (SMTP server configuraiton),in the central administraiton tool.

the benefit of the second choice,you don't need to store any other configuration for your SMTP server on your code,this code will directly use the sharepoint configuration and free your mind of SMTP configurations, if the sharepoint is configured propely and send email notification (throught workflows for example),then you code will work as well

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by gurney on Friday, July 11, 2008 4:39 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Friday, September 05, 2008 11:21 PM