Saturday, January 13, 2007
TIP: Sending mail from SharePoint
Sending an e-mail from code in .NET isn't very hard, but you will have to configure an SMTP server. When your code runs inside SharePoint (WSS 3 or MOSS 2007), this shouldn't be necessary, as SharePoint already knows a working SMTP server (it uses this to send out alert e-mails and other mail). To use this and bypass the configuration bogus, send e-mail using this snippet:
using Microsoft.SharePoint.Utilities;
SPUtility.SendEmail(SPContext.Current.Web, false, false,
"to-address@mail.com", "E-mail title",
"E-mail body");Labels: sharepoint
Comments:
Links to this post:
<< Home
Hi,
You are really a expert in webpart!
Would like to consult with you how do I develop sharepoint webpart with VS2005? Do I develop it directly with VS2005? I do not see any sharepoint templates in VS2005. How should I start to develop it? thanks~
Sophia
You are really a expert in webpart!
Would like to consult with you how do I develop sharepoint webpart with VS2005? Do I develop it directly with VS2005? I do not see any sharepoint templates in VS2005. How should I start to develop it? thanks~
Sophia
@Sophia: you may want to check out the VS.NET extensions for Sharepoint.
http://www.microsoft.com/downloads/details.aspx?FamilyID=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&DisplayLang=en
It contains, among other things, a web part template.
http://www.microsoft.com/downloads/details.aspx?FamilyID=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&DisplayLang=en
It contains, among other things, a web part template.
Hi,
Im experiencing problems with this method. When i send an email made with html formatting it sometimes chops of the last part of it making the mail incomplete. it almost seems like it has a max length. Have you ever experienced anything similar?
Im experiencing problems with this method. When i send an email made with html formatting it sometimes chops of the last part of it making the mail incomplete. it almost seems like it has a max length. Have you ever experienced anything similar?
I got a error when I try to include this code int Form authentication.
Event code: 4005
Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.
Event time: 30/08/2007 15:42:07
Event time (UTC): 30/08/2007 13:42:07
Event ID: 9bd0e4cd7ed149928910c444f36daef2
Event sequence: 140
Event occurrence: 64
Event detail code: 50202
Event code: 4005
Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.
Event time: 30/08/2007 15:42:07
Event time (UTC): 30/08/2007 13:42:07
Event ID: 9bd0e4cd7ed149928910c444f36daef2
Event sequence: 140
Event occurrence: 64
Event detail code: 50202
Middag, I am trying to have a SharePoint List I created send an e-mail to the e-mail listed in an item when the item has its status changed to "Received". In this case, this is a job application system that HR will use at a company I am consulting with. They want the system to generate a Thank You for contacting is. We will be in touch if a suitable position becomes available for your qualifications" or something like that. How can I have a field such as a Status field kick off an e-mail?
Dank u wel.
Bill Goss
qualitysystem@comcast.net
978-766-4164
Dank u wel.
Bill Goss
qualitysystem@comcast.net
978-766-4164
Bill,
To do that, you would have to write an event handler for the list. Check out the wssevents.wmv video here: http://www.microsoft.com/downloads/details.aspx?FamilyID=BD5C77B0-F556-4136-8730-1D7FEEAE0A42&displaylang=en
In the event handler you would have code like you see in the web log above. You may also need to do impersonation to gain the right privileges to send mail.
To do that, you would have to write an event handler for the list. Check out the wssevents.wmv video here: http://www.microsoft.com/downloads/details.aspx?FamilyID=BD5C77B0-F556-4136-8730-1D7FEEAE0A42&displaylang=en
In the event handler you would have code like you see in the web log above. You may also need to do impersonation to gain the right privileges to send mail.
If you need higher privileges for sending mail, you can use the RunWithElevatedPrivileges method: http://msdn2.microsoft.com/en-us/library/aa543467.aspx
Post a Comment
Links to this post:
<< Home



