Hi,
I want to send an email from one to another mail and also want to send an attachment when i use my code in client machine it works, but if i used after putting it in web it didn,t work.web link is www.akdpl.com/carrer.aspx.
I am giving my code also
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Text;
using System.Configuration;
using System.Data.OleDb;
//using System.Xml.Linq;
using System.Net.Mail;
using System.Net.Mime;
using System.Net;
protected void Button1_Click1(object sender, EventArgs e)
{
try
{
string str_from_address = "contact@akdpl.com";
string str_name = "A K Dutta & Co. Pvt. Ltd.";
string str_to_address = txteid.Text;
MailMessage email_msg = new MailMessage();
email_msg.From = new MailAddress(str_from_address, str_name);
email_msg.Sender = new MailAddress(str_from_address, str_name);
email_msg.ReplyTo = new MailAddress(str_from_address, str_name);
email_msg.To.Add(str_to_address);
email_msg.Subject = "Request Confirmation"
email_msg.Body = "Thank you for showing your interest in A K Dutta & Co. Pvt. Ltd. .We will get back to you very soon"
email_msg.Priority = MailPriority.Normal;"
SmtpClient mail_client = new SmtpClient();
NetworkCredential network_cdr = new NetworkCredential();
network_cdr.UserName = str_from_address;
network_cdr.Password = "password";
mail_client.Host = "smtp.akdpl.com";
mail_client.UseDefaultCredentials = false;
mail_client.Credentials = network_cdr;
mail_client.Send(email_msg);
//Its Working upto Here a mail is going but after that it didn't work
sendmail();
txteid.Text =""
txtname.Text = ""
txtmessage.Text = ""
txtcon.Text = ""
txtorg.Text = ""
Response.Redirect("thanksdet.html");
}
catch (SmtpException df)
{
Response.Write(df.ToString());
}
}
void sendmail()
{
string str_from_address = "contact@akdpl.com";
string str_name = txtname.Text;
string str_to_address = "contact@akdpl.com";
MailMessage email_msg = new MailMessage();
email_msg.From = new MailAddress(str_from_address, str_name);
email_msg.Sender = new MailAddress(str_from_address, str_name);
email_msg.ReplyTo = new MailAddress(str_from_address, str_name);
email_msg.To.Add(str_to_address);
email_msg.Subject = "Request logged";
Attachment s = new Attachment(FileUpload1.PostedFile.FileName);
email_msg.Attachments.Add(s);
email_msg.Body = "Candidate Name is " + txtname.Text + " Email Id: <" + txteid.Text + ">" + " Date of Birth : " + txtdob.Text + " Address : " + txtcon.Text + " Phone Number: " + txtphone.Text + " Education Qualification : " + txtedu.Text + " Post Applied For : " + txtpost.Text + " Year Experienced : " + txtyear.Text;
email_msg.Priority = MailPriority.Normal;
SmtpClient mail_client = new SmtpClient();
NetworkCredential network_cdr = new NetworkCredential();
network_cdr.UserName = str_from_address;
network_cdr.Password = "password";
mail_client.Host = "smtp.akdpl.com";
mail_client.UseDefaultCredentials = false;
mail_client.Credentials = network_cdr;
mail_client.Send(email_msg);
}
}
}