You must Sign In to post a response.
  • Category: ASP.NET

    Mail with attachment not working in live server

    Hi,

    I have written code for sending mail with attachment it is working good in local but it does not work in live server if we send mail with out attachment it works good in live server also.Can you please any one help me that how to fix this issue?

    Thank you.
  • #768535
    Hi Ram,

    have you checked the size of the attachment. is it giving any time out error or any other exception.

    Can you please post code that is attaching the attachment with the mail.
    It will be better to verify the exception.

  • #768536
    Yes Thank you .
    It does not give any time out error i have used this code

    string filename = string.Empty;
    string flname = string.Empty;
    string fileext = System.IO.Path.GetExtension(attachment_FileUpload.PostedFile.FileName).ToLower();
    if (fileext != string.Empty)
    {
    string nameId = Guid.NewGuid().ToString();
    nameId = nameId.Substring(0, 6);
    filename = "attachment" + "-" + nameId + fileext;
    attachment_FileUpload.PostedFile.SaveAs(Server.MapPath("../Images/Mail/" + filename));
    flname = Server.MapPath("../Images/Mail/" + filename);
    }

    string mailBcc = ConfigurationManager.AppSettings["mailbcc"].ToString();
    pBAL.SendMail("", toaddress_txt.Text.Trim(), subject_txt.Text, emailcontent_txt.Text, mailBcc, "", flname);
    if (orderid_hfld.Value == "0")
    {
    Clr();
    submit_btn.Visible = true;
    }
    info_div.Attributes.Add("class", "information");
    Popheading_Lbl.Text = "Successful Message";
    PopMsg_Lbl.Text = "Dedicated Order has been created successfully and mail send to charter";
    PopupOk_Btn.Focus();
    popupmsg_ajxmpe.Show();
    mail_div.Visible = false;
    //chkchartername_lbl.Text = string.Empty;
    //chkcharterid_lbl.Text = string.Empty;
    attachment_FileUpload.Dispose();

  • #768551
    Hi,

    do you have a logs for the same, please check the stacktrace in logs, so that we can help you better.

    And check whether it moves to inside fileext condition or not, if it moves check where it get failed.

    Hope this helps you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments