关于邮件发送 [英] Regarding Mail Send

查看:38
本文介绍了关于邮件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的密码!!
我正在使用以下名称空间发送邮件,

Here is my Code!!
i am using following namespace for sending mails,

System.Web.Mail; 

邮件尚未发送,我的编码有问题吗?

The mail has not been sent, any problem in my coding?

protected void btSend_Click(object sender, EventArgs e)
    {
        if (!(txtMymail.Text.Equals(string.Empty)) && !(txtRecivermail.Text.Equals(string.Empty)) && !(txtSubject.Text.Equals(string.Empty)) && !(txtBody.Text.Equals(string.Empty)))
        {
            //SmtpClient mailClient = new SmtpClient("smtp.gmail.com");
            string from = txtMymail.Text.ToString();
            string to = txtRecivermail.Text.ToString();
            string subject = txtSubject.Text.ToString();
            string body = txtBody.Text.ToString();
            System.Web.Mail.MailMessage mail12 = new System.Web.Mail.MailMessage();
            mail12.From =from;
            mail12.To = to;
            mail12.Subject = subject;
            mail12.Body = body;

            mail12.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com");
            mail12.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 587);
            mail12.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
            mail12.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "vinoar@gmail.com");
            mail12.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "vinoth123");

            try
            {
                System.Web.Mail.SmtpMail.Send(mail12);
                //mailClient.Send(mail12);
            }
            catch (Exception exp)
            {
                lbErr.Visible = true;
                lbErr.ForeColor = Color.Red;
                lbErr.Text = "Error During Send mail" + exp.ToString();
            }
            lbErr.Visible = true;
            lbErr.ForeColor = Color.Blue;
            lbErr.Text = "Mail Send";
        }
        else
        {
            lbErr.Visible = true;
            lbErr.ForeColor = Color.Red;
            lbErr.Text = "Fill The Fields";
        }
    }

推荐答案

由于您尚未指出发送电子邮件时面临的主要问题:
可能是由于各种原因.您需要一一看待它们.港口开放吗?防火墙权限到位了吗?
进一步确保已正确配置SMTP配置.
Since you have not pointed what king of issue you are facing while sending emails:
It can be because of various reasons. You need to look at them one by one. Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration properly.


这篇关于关于邮件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆