发送电子邮件模块的代码 [英] code for send email module

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

问题描述

vb.net中发送电子邮件的代码是什么

whats the code for send email in vb.net

推荐答案

这是C#中的代码

自行转换.也是一个地方.尝试先用Google搜索您的查询.


Here is the code in C#

Convert it by youself. Also an adivce. Try and google your query first.


using System.Net.Mail;
using System.Net;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmitt_Click(object sender, EventArgs e)
    {

        MailMessage mail = new MailMessage();
        mail.Subject = "Enquiry";
        mail.Body = "<b>Name :</b>" + txtName.Text + "<br/> +<b>Address:</b>" + txtAddress.Text + "<br/><b>Email-Id :</b>" + txtEmailId.Text  + "<br/><b>city :</b>" + txtCity.Text + "<br/><b>Phone :</b>" + txtPhoneNo.Text + "<br/><b>Organisation:</b>" + txtOrganisation.Text + "<br/><b>Comment:</b>" + txtComment.Text;
        // mail.Body += "<br><b>Password:</b>" + TextBox2.Text;
        // mail.Body += "<br><b>secret Code:</b>" + chi.ToString();
        //the displayed "from" email address 
        mail.From = new System.Net.Mail.MailAddress("abc@gmail.com", "Enquiry From Website");
        mail.IsBodyHtml = true;
        //mail.BodyEncoding = System.Text.Encoding.Unicode; 
        //mail.SubjectEncoding = System.Text.Encoding.Unicode; 
        //Add one or more addresses that will receive the mail 
        mail.To.Add("info@gmail.com");
        //create the credentials 
        NetworkCredential cred = new NetworkCredential("abc@gmail.com", "xyz[what ever the password is]");
        //create the smtp client...these settings are for gmail 
        SmtpClient smtp = new SmtpClient("smtp.gmail.com");
        smtp.UseDefaultCredentials = false;
        smtp.EnableSsl = true;
        //credentials (username, pass of sending account) assigned here 
        smtp.Credentials = cred;
        smtp.Port = 587;
        //let her rip 
        smtp.Send(mail);
        clear();

    }
    private void clear()
    {
        txtComment.Text = "";
        txtEmailId.Text = "";
        txtName.Text = "";
        txtOrganisation.Text = "";
        txtPhoneNo.Text = "";
        txtCity.Text = "";
        txtAddress.Text = "";
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        clear();
    }
}


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

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