use those Classes in the .Net Environment you should include
Namespaces:
using System.Web.Mail;
using System.Web.Util;
Assembly:
System.Web.dll
You can call the Send method in two ways.
1. By passing MailMessage as a parameter
public static void Send(MailMessage);
Here MailMessage is a class.
MailMessage mailMsg = new MailMessage();
mailMsg .From = "from@fromServer.com";
mailMsg .To = "to@toServer.com";
mailMsg .Cc = "cc@ccServer.com"";
mailMsg .Bcc = "bcc@bccServer.com";
mailMsg .Subject = "SubjectOfTheMailString";
mailMsg .Body = "BodyOfTheMailString";
SmtpMail.Send(mailMsg );
2. Direct method.
public static void Send(string from , string to, string subject, string messageText);
Prameters Description
from Email address of sender
to Email address of recipient
subject Email subject line.
messageText Body of Email message
Example:
SmtpMail.Send("mcb@mindcracker.com", "webmaster@mindcracker.com", "Subject", "Message body");
The MailMessage Class
The MailMessage class can be used to send mails with cc, bcc or attachments. The MailMessage constructor initializes a new instance of the MailMessage class. It doesn't take any parameters.
MailMessage mail = new MailMessage();
Members Description
Bcc Specifies a semicolon-separated list of email addresses that will receive a private copy of the email message.
Body Indicates the body content of the email message.
BodyEncoding Indicates the encoding type of the email message.
BodyFormat Indicates the type of the email message body (text or html).
Cc Specifies a semicolon-separated list of email addresses that will receive a copy of the email message.
From Indicates the email address of sender.
Priority Indicates the priority of the email message.
Subject Indicates the subject line of the email.
To Indicates the email address of the recipient
UrlContentBase Indicates the base of all relative URLs used within an HTML-encoded message.
Attachments List of "MailAttachments" to be transmitted with the message. This property is read-only.
Headers Indicates the dictionary of custom headers to be transmitted with the message. This property is read-only.
Each member of this class are pretty easy to understand. Say you want to send an attachment with the mail.
You use Attachment member to attach the mail. Say I want to attach mcb.jpg with the mail.
mail.Attachments.Add(new MailAttachment(@"C:\mcb.jpg"));
Each member of this class are pretty easy to understand. Say you want to send an attachment with the mail. You use Attachment member to attach the mail.
Other MailMessage members have been used in the above example.
Thursday, September 25, 2003
SmtpMail.Send(), MailMessage, MailAttachment
at 11:40 PM Posted by roni schuetz
Labels: .net, code sample
Subscribe to:
Post Comments (Atom)
Shared Cache - .Net Caching made easy
All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.
No comments:
Post a Comment