bsp; string MessageBody) { MailMessage message = new MailMessage(); message.From = MessageFrom; message.To = MessageTo; message.Subject = MessageSubject; message.BodyFormat = MailFormat.Text; message.Body = MessageBody;
try { System.Console.WriteLine("Sending outgoing message"); SmtpMail.Send(message); } catch( System.Web.HttpException exHttp ) { System.Console.WriteLine("Exception occurred:" + exHttp.Message); } } } }
Sending a Message with an Attachment Sample Code The following sample code contains a C#-based Windows Console application that shows how to send an e-mail message that includes an attachment. This is done by creating instances of the MessageAttachment class and then adding them to the message through the Attachments collection.
using System; using Sy << 上一页 [11] [12] [13] [14] [15] 下一页 |