หอจดหมายเหตุ

วิธีการส่งอีเมลจาก webpart ในมอสส์ 2007

Hi Devs,
ต่อไปนี้เป็นชิ้นส่วนของรหัสที่จะส่งอีเมล์จาก webpart.

การใช้ระบบ;
ใช้ System.Collections.Generic;
ใช้ System.ComponentModel;
ใช้ System.Text;
ใช้ System.Web;
ใช้ System.Web.UI;
ใช้ System.Web.UI.WebControls;
ใช้ System.Collections.ObjectModel;
ใช้ Microsoft.SharePoint.Utilities;
ใช้ Microsoft.SharePoint;
using System.Data;
ใช้ System.Collections;
sendmail namespace
{
sendmail สาธารณะระดับ : Microsoft.SharePoint.WebPartPages.WebPart
{
ส่วนตัว txtTo ช่อง;
btnSendMail ปุ่มส่วนตัว;
CreateChildControls ป้องกันแทนที่เป็นโมฆะ()
{
txtTo = ช่องใหม่();
this.Controls.Add(txtTo);
btnSendMail = ปุ่มใหม่();
= btnSendMail.Text “ส่งอีเมล์”;
btnSendMail.Click = Eventhandler ใหม่(SendMail_Click);
this.Controls.Add(btnSendMail);
}
SendMail_Click ถือเป็นโมฆะ(ผู้ส่งวัตถุ, EventArgs E)
{
SPSite _site = SPSite ใหม่(HttpContext.Current.Request.Url.ToString());
SPWeb _site.OpenWeb _web =();
_web.AllowUnsafeUpdates = จริง;
SPUtility.SendEmail(_web, เท็จ, เท็จ, txtTo.Text, “อีเมล์ทดสอบ”, “เนื้อหาของข้อความข้อความ”);
_web.Dispose();
_site.Dispose();
}
}
}

สร้าง webpart และลงทะเบียนเป็น SafeControl

ปล่อยให้ตอบกลับ

คุณสามารถใช้ เหล่านี้แท็ก

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>