ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sending E-Mail with C-Sharp

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#)
View previous topic :: View next topic  
Author Message
x-raysteve



Joined: 01 Feb 2006
Posts: 53

PostPosted: Sat Feb 04, 2006 6:05 pm    Post subject: Sending E-Mail with C-Sharp Reply with quote

I was looking for a way to send e-mail in C# via SMTP and came across this tip. I thought I would pass it on here for anyone else who might be trying to do the same thing:

Quote:
using (MailMessage mailMessage = new MailMessage(new MailAddress(fromTextBox.Text),
new MailAddress(toTextBox.Text)))
{
mailMessage.Body = bodyTextBox.Text;
mailMessage.Subject = subjectTextBox.Text;

try
{
SmtpClient smtpClient = new SmtpClient(serverAddressTextBox.Text);
smtpClient.Send(mailMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial