Hola Devs,
El següent és el tros de codi per enviar per correu electrònic de part web.
utilitzant el Sistema;
utilitzant System.Collections.Generic;
utilitzant System.ComponentModel;
utilitzant System.Text;
utilitzant System.Web;
utilitzant System.Web.UI;
utilitzant System.Web.UI.WebControls;
utilitzant System.Collections.ObjectModel;
utilitzant Microsoft.SharePoint.Utilities;
utilitzant Microsoft.SharePoint;
using System.Data;
utilitzant System.Collections;
espai de noms SendMail
{
public class SendMail : Microsoft.SharePoint.WebPartPages.WebPart
{
txtTo TextBox privat;
btnSendMail Botó privat;
protected override void CreateChildControls()
{
txtTo = new TextBox();
this.Controls.Add(txtTo);
btnSendMail = new Button();
btnSendMail.Text = “Send Email”;
btnSendMail.Click = new EventHandler(SendMail_Click);
this.Controls.Add(btnSendMail);
}
void SendMail_Click(object sender, EventArgs i)
{
SPSite _site = new SPSite(HttpContext.Current.Request.Url.ToString());
SPWeb _web = _site.OpenWeb();
_web.AllowUnsafeUpdates = true;
SPUtility.SendEmail(_web, fals, fals, txtTo.Text, “Test Email”, “Text Body Message”);
_web.Dispose();
_site.Dispose();
}
}
}
Create the WebPart and register it as SafeControl
Deixa una resposta