TopL TopM TopR
MiddleL
Author: Adam Heitke Created: 9/17/2008 10:47 AM
Adam's lessons learned in the .Net arena and as an Enterprise IT Consultant.

Short method for creating and sending an email message using SMTP:

C#

using System.Net.Mail; .... private void SendSMTPMessage()         {             //declare a new message             MailMessage message = new MailMessage();                         //Add Recipient to Message, can create multiple recipients if desired             message.To.Add("user@mail.com");

            //message sent from             message.From = new MailAddress("sender@mail.com");                         //message subject and body             message.Subject = "Sample Message Subject";             message.Body = "Sample message content";

            //create the smtp client             SmtpClient smtp = new SmtpClient("my.smtp.server");

            //I had to add this to get my message to send on Windows Server 2003 and IIS 6             smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

            //attempt to send message             smtp.Send(message);        ...

Read More »

MiddleR
BottomL BottomM BottomR
Copyright 2008 Capriccio Software, Inc.
Privacy Statement | Terms Of Use