C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

Email sending---urgent


Posted Date: 04 Nov 2008      Posted By: pn      Member Level: Silver     Points: 1   Responses: 4



Hi
I have the class to send email using smtp commands and socket.
but now i need to attach wav files to the email.if anybody knows the code
please send me the code or any links.i am not using System.web.mail or System.Net.mail namespaces.I have the separate class for that.

am using vs2003,c#,asp.net...

Please its very urgent...

Thanks





Responses

Author: Anil Kumar Pandey    04 Nov 2008Member Level: DiamondRating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

hi,


u can use the attachment option for sending the mails with the attachments..



please refer the foloowing code for that..


protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailAddress SendFrom = new MailAddress(txtFrom.Text);
MailAddress SendTo = new MailAddress(txtTo.Text);

MailMessage MyMessage = new MailMessage(SendFrom, SendTo);

MyMessage.Subject = txtSubject.Text;
MyMessage.Body = txtBody.Text;

Attachment attachFile = new Attachment(txtAttachmentPath.Text);
MyMessage.Attachments.Add(attachFile);

SmtpClient emailClient = new SmtpClient(txtSMTPServer.Text);
emailClient.Send(MyMessage);

litStatus.Text = "Message Sent";
}
catch (Exception ex)
{
litStatus.Text=ex.ToString();
}
}



Regards
Anil Pandey

Thanks & Regards
Anil Kumar Pandey



Author: archana    04 Nov 2008Member Level: GoldRating: 3 out of 53 out of 53 out of 5     Points: 3

Hi
Refer to

http://www.systemwebmail.com/

Code for Mailing is as follows

public string SendMailToUser(string MailID, string mailmsg, string mailSubject)
{
try {
SmtpClient smtpAdmin = new SmtpClient();
string ToAddress = MailID;
MailMessage MailMessAdmin = new MailMessage("abc@yahoo.com", ToAddress);
MailMessAdmin.Subject = mailSubject;
MailMessAdmin.Body = mailmsg;
smtpAdmin.Send(MailMessAdmin);
return ToAddress;
}
catch (Exception ex) {
throw new Exception(ex.Message);
}
}
----------------------------------------------------------------
In web.config: Under configuration section
<system.net>
<mailSettings>
<smtp>

<network host="127.0.0.1" port="25" userName="abc1@gamil.com" password="abc123"/>
</smtp>

</mailSettings>
</system.net>
-------------------------------------------------------------
Configure SMTP settings



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to make online payment transaction
Previous : sending emails from outlook in asp.net using c#
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use