vb.net126邮箱 vba登录邮箱( 七 )


client.UseDefaultCredentials = false
dim credentials as new System.Net.NetworkCredential(credentialUserName, pwd)
client.EnableSsl = true
client.Credentials = credentials
dim mail as new System.Net.Mail.MailMessage(sentFrom, message.Destination)
mail.Subject = message.Subject
mail.Body = message.Body
return client.SendMailAsync(mail)
end function
要一段VB.NET发邮件的代码'创建发件连接,根据vb.net126邮箱你vb.net126邮箱的发送邮箱vb.net126邮箱的SMTP设置填充
Dim smtp As New System.Net.Mail.SmtpClient("smtp.163.com", 25)
'发件邮箱身份验证,参数分别为 发件邮箱登录名和密码
smtp.Credentials = New System.Net.NetworkCredential("用户名", "密码")
'创建邮件
Dim mail As New System.Net.Mail.MailMessage()
'邮件主题
mail.Subject = "邮件主题"
'主题编码
mail.SubjectEncoding = System.Text.Encoding.GetEncoding("GB2312")
'邮件正文件编码
mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312")
'发件人邮箱
mail.From = New System.Net.Mail.MailAddress("example@163.com")
'邮件优先级
mail.Priority = System.Net.Mail.MailPriority.Normal
'HTML格式的邮件,为false则发送纯文本邮箱
mail.IsBodyHtml = True
'邮件内容
mail.Body = "邮件正文内容"
【vb.net126邮箱 vba登录邮箱】'添加收件人,如果有多个,可以多次添加
mail.To.Add("收件人地址")
'定义附件,参数为附件文件名,包含路径,推荐使用绝对路径
'如果不需要附件,下面三行可以不要
Dim a As New System.Net.Mail.Attachment("附件文件")
'附件文件名,用于收件人收到附件时显示的名称
a.Name = "附件文件名"
'加入附件,可以多次添加
mail.Attachments.Add(a)
'发送邮件
Try
smtp.Send(mail)
MessageBox.Show("发送成功")
Catch
MessageBox.Show("发送失败")
Finally
mail.Dispose()
End Try
请问asp.net 注册会员后自动发送邮件到会员所填写的邮箱这个功能怎么实现呢? 用vb.net! 谢谢大家了!发邮件vb.net126邮箱,最好能有自己vb.net126邮箱的邮件服务器,没有的话,也可以用网易或139邮箱等 , 示例代码:
SmtpClient client = new SmtpClient(smtp, smtpport)
{
UseDefaultCredentials = false,
Credentials = new NetworkCredential(登录名, 密码),
DeliveryMethod = SmtpDeliveryMethod.Network
};
var from = new MailAddress("发件人邮箱", "发件人姓名");
MailMessage message = new MailMessage
{
Sender = from,
From = from,
IsBodyHtml = false,
//Priority = MailPriority.High,
BodyEncoding = Encoding.UTF8
};
/*添加收件人列表*/
message.To.Add(new MailAddress("收件人邮箱", "收件人姓名"));
message.Subject = 邮件标题;
message.Body = 邮件内容;
//添加附件
message.Attachments.Add(new Attachment("C:\\abc.txt"));
client.Send(message);
vb.net126邮箱的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vba登录邮箱、vb.net126邮箱的信息别忘了在本站进行查找喔 。

推荐阅读