Start New Discussion within our Web Development Community

Hello people,

Please i need your help here. I have been trying to send mail in my, but no success.Click this link and try sending mail to see the error:"". Honestly i don't know where i am going wrong. Here is my code behind:

 protected void ImageButton_Submit_Click(object sender, ImageClickEventArgs e)
            MailMessage mMailMessage = new MailMessage();

            mMailMessage.From = new MailAddress(HttpUtility.HtmlEncode(TextBoxEmail.Text));
            mMailMessage.To.Add(new MailAddress(""));

            // mMailMessage.Bcc.Add(new MailAddress(bcc));
            // mMailMessage.CC.Add(new MailAddress(cc));

            mMailMessage.Subject = "From:" + HttpUtility.HtmlEncode(TextBoxYourName.Text) + "-" + HttpUtility.HtmlEncode(TextBoxSubject.Text);
            mMailMessage.Body = HttpUtility.HtmlEncode(EditorEmailMessageBody.Content);
            mMailMessage.IsBodyHtml = true;
            mMailMessage.Priority = MailPriority.Normal;
            SmtpClient mSmtpClient = new SmtpClient("");
            LabelMessage.Text = "Thank You - Your Message was sent.";

        catch (Exception exp)
            throw new Exception("ERROR: Unable to Send Contact - " + exp.Message.ToString(), exp);


This code is in VB, but you should be able to see what's going on. If not, let me know.

    Dim Msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
    Dim MailObj As New System.Net.Mail.SmtpClient("")

    Msg.From = New System.Net.Mail.MailAddress("", "Webform")
    Msg.To.Add(New System.Net.Mail.MailAddress("", "denmarkstan"))
    Msg.IsBodyHtml = "False"
    Msg.Subject = "From:" + HttpUtility.HtmlEncode(TextBoxYourName.Text) + "-" + HttpUtility.HtmlEncode(TextBoxSubject.Text);

    Msg.Body = "Some message"

    MailObj.UseDefaultCredentials = False
    MailObj.Credentials = New System.Net.NetworkCredential("email_user_name", "email_password")
    MailObj.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

    Catch ex As Exception

    End Try
This article has been dead for over six months. Start a new discussion instead.