Hi to Everybody,
I have use the C#.net for send the E-mail as follows
MailMessage omsg = new MailMessage();
omsg.From = new MailAddress("sa thiy.03@gmail.c om");
omsg.To.Add(new MailAddress(txt Email.Text));
//omsg.Subject = txtSubject.Text ;
//omsg.Body = txtContent.Text ;
if (txtSubject.Tex t.Trim() != "")
{
omsg.Subject = txtSubject.Text .Trim();
}
else
{
omsg.Subject = "No Subject";
}
//omsg.IsBodyHtml = true;
omsg.Body = txtContent.Text .Trim();
omsg.Attachment s.Add(new Attachment("d://download.txt")) ;
SmtpClient client = new SmtpClient("192 .168.1.5", 25);
client.Delivery Method = SmtpDeliveryMet hod.Network;
client.Credenti als = System.Net.Cred entialCache.Def aultNetworkCred entials;
//client.Host = ;
try
{
client.Send(oms g);
}
catch (SmtpFailedReci pientsException ex)
{
for (int i = 0; i < ex.InnerExcepti ons.Length; i++)
{
Response.Write( ex.InnerExcepti ons[i].FailedRecipien t.ToString());
}
}
If i send the mail with attach file it did not receive but it received without attachment file.
Please give me the solution to send e-mail with attached file.
Thanks
I have use the C#.net for send the E-mail as follows
MailMessage omsg = new MailMessage();
omsg.From = new MailAddress("sa thiy.03@gmail.c om");
omsg.To.Add(new MailAddress(txt Email.Text));
//omsg.Subject = txtSubject.Text ;
//omsg.Body = txtContent.Text ;
if (txtSubject.Tex t.Trim() != "")
{
omsg.Subject = txtSubject.Text .Trim();
}
else
{
omsg.Subject = "No Subject";
}
//omsg.IsBodyHtml = true;
omsg.Body = txtContent.Text .Trim();
omsg.Attachment s.Add(new Attachment("d://download.txt")) ;
SmtpClient client = new SmtpClient("192 .168.1.5", 25);
client.Delivery Method = SmtpDeliveryMet hod.Network;
client.Credenti als = System.Net.Cred entialCache.Def aultNetworkCred entials;
//client.Host = ;
try
{
client.Send(oms g);
}
catch (SmtpFailedReci pientsException ex)
{
for (int i = 0; i < ex.InnerExcepti ons.Length; i++)
{
Response.Write( ex.InnerExcepti ons[i].FailedRecipien t.ToString());
}
}
If i send the mail with attach file it did not receive but it received without attachment file.
Please give me the solution to send e-mail with attached file.
Thanks
Comment