Hello people,

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

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

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

            // 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("mail.ckcayangba.com");
            mSmtpClient.Send(mMailMessage);
            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("mail.ckcayangba.com")

    Msg.From = New System.Net.Mail.MailAddress("mail.ckcayangba.com", "Webform")
    Msg.To.Add(New System.Net.Mail.MailAddress("denmarkstan@yahoo.com", "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

    Try
        MailObj.Send(Msg)
    Catch ex As Exception

    End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.