Tuesday, February 10, 2009

Sending mail containing attachements using CDONTS in .Net

Hi,

Chalo aaj attachement wali mail send karte hai Using CDONTS and asp.net.

Here are the steps to send mail using CDONTS:

1) Add refrence to the CDONTS.dll.

2) Register the dll using:

Start + Run, regsvr32 c:\cdonts.dll

3) Code to sned email:
s1 = FileUpload1.PostedFile.FileName;
Response.Write(s1+” s1
”);
Response.Write(s2 + “ s2
”);
Response.Write(s3 + “ s3
”);
NewMailClass Obj = new NewMailClass();
Obj.MailFormat = 0;
Obj.BodyFormat = 0;

// we can use physical path of any file on the place of FileUpload1.PostedFile.FileName. And ‘my file’ will be the name of the file sent.

Obj.AttachFile(FileUpload1.PostedFile.FileName, “my file”, 1);

Obj.Send(”nitin.sender@anyfakeid.com”, “nitin.reciever@anyrealid.com”, “mail subject”, “mail message body”, 1);

thanks,

Nitin Dhiman.

No comments:

Post a Comment