4
Reply

send mail with attachment files using godaddy (asp.net)

Divya R

Divya R

Feb 25 2016 1:13 AM
427
hai friends,
i need help ..
 
i want to send mail with attachment files .my code run successful in locally.but not support godaddy...
 
If i host my prg into godaddy only send details but attachment files not in my mail.please help me.
 
 
am using below code
 
bool confirmation = false;
System.Net.Mail.MailAddress mm = new MailAddress("DomainEmailid", "Job Applying Form Details");
string Name = txtFrom.Text;
string email = txtTo.Text;
string Phone = txtPhone.Text;
string Message = txtBody.Text;
string body = string.Format("<table width=\"600px\" height=\"400px\" border=\"3\"style=\"font-family:Courier New, Courier, monospace; border-style: solid; border-color:#591434; font-size:25px;\"><tr bgcolor=\"#fff\" style=\"color: #000000\"><td colspan=\"2\" align=\"center\" >Send Enquery<br></td></tr><tr><td bgcolor=\"#fff\" style=\"color: #000000\">Name :</td><td bgcolor=\"#fff\" style=\"color: #000000\">{0}</td></tr><tr><td bgcolor=\"#fff\" style=\"color: #000000\">Email-Id :</td><td bgcolor=\"#fff\" style=\"color: #000000\">{1}</td></tr><tr><td bgcolor=\"#fff\" style=\"color: #000000\">Phone No:</td><td bgcolor=\"#fff\" style=\"color: #000000\">{2}</td></tr><tr bgcolor=\"#fff\" style=\"color: #000000\"></tr><tr><td bgcolor=\"#fff\" style=\"color: #000000\">Comments:</td><td bgcolor=\"#fff\" style=\"color: #000000\">{3}</td></tr><tr bgcolor=\"#fff\" style=\"color: #000000\"></tr></table>", Name, email, Phone, Message);
string mailbody = body;
string mailto = " [email protected]";
string mailsubject = "Job Applying Form Details";
MailMessage mailmessage = new MailMessage("Domainemailid", mailto);
mailmessage.To.Add(mailto);
mailmessage.Subject = mailsubject;
mailmessage.Body = mailbody;
if (fileUpload1.HasFile)
{
string FileName = Path.GetFileName(fileUpload1.PostedFile.FileName);
mailmessage.Attachments.Add(new Attachment(fileUpload1.PostedFile.InputStream, FileName));
}
mailmessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "relay-hosting.secureserver.net"; //-- Donot change.
smtpClient.Port = 25; //--- Donot change
smtpClient.EnableSsl = false;//--- Donot change
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("Domain Emailid", "PWD");
smtpClient.Send(mailmessage);
string message = string.Empty;
Response.Write("Mail Sent!!!");
confirmation = true;
if (confirmation == true)
{
Response.Write("<script language='javascript'>alert(' Successfully Registered!!!')</script>");
}
 
 
 

Answers (4)
Next Recommended Forum