大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
在Identity2.0里面封装了IIdentityMessageService接口,可以用来发送接收邮件。
成都创新互联是专业的广德网站建设公司,广德接单;提供成都做网站、成都网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行广德网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
看看
Imports System.Threading.Tasks
Imports System.Security.Claims
Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.EntityFramework
Imports Microsoft.AspNet.Identity.Owin
Imports Microsoft.Owin
Imports Microsoft.Owin.Security
public function SendAsync(message as IdentityMessage) as task
dim credentialUserName = "邮箱登录名"
dim sentFrom = "你的邮箱地址"
dim pwd= "邮箱登录密码";
dim client as new System.Net.Mail.SmtpClient("smtp服务器地址")
client.Port = 25'mtp邮件服务器端口
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
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
有两种发法哦,代码如下,有点乱,如果需要打包范例文件我发给你?
Dim fpath As String
'Dim xlApp As Excel.Application '定义EXCEL类
'Dim xlBook As Excel.Workbook '定义工件簿类
'Dim xlsheet As Excel.Worksheet '定义工作表类
Dim bh As String
Dim sbh As String
Dim strMailAdd As String '收信人地址 如:yin07@21cn.com
Dim strAddName As String '收信人姓名 如:影是
Dim strSubject As String '发信的主题
Dim strNoteText As String '发信的内容
Dim strMailToo As String '发信人地址
Dim strTooName As String '发信人姓名
Option Explicit
Option Compare Text
Private WithEvents poSendMail As vbSendMail.clsSendMail
Private bSendFailed As Boolean
Private Sub Command1_Click()
On Error Resume Next
sbh = Trim(OLE1.object.Worksheets("sheet1").Cells(5, 3).Value)
If sbh = "" Then
MsgBox "请填写小样编号!", vbOKOnly, "警告"
Else
'strMailAdd = "xxx@mizuda.net" '收信人地址,
'strAddName = "sdf" '收信人姓名sdf
'strNoteText = "请查收计划单" + sbh + "技术评审结果" '发信的内容
'strSubject = sbh + "合约技术评审结果" '发信的主题
'MAPISession1.DownLoadMail = False '不立即进入用户的收信箱(非常有用的,不信你设为 True试一下)
'MAPISession1.LogonUI = True '显示一个启动动话框
'MAPISession1.UserName = "lqgdf"
'MAPISession1.Password = "2fd@mizuda"
'MAPISession1.SignOn '这因该算激活吧,注意:不要把FoxMail在IE中设置为默认电子邮件,否则会出现错误
'MAPIMessages1.SessionID = MAPISession1.SessionID
'MAPIMessages1.Compose '构成一条消息
'MAPIMessages1.RecipAddress = strMailAdd '收信人地址
'MAPIMessages1.ResolveName
'MAPIMessages1.RecipDisplayName = strAddName '收信人姓名
'MAPIMessages1.MsgSubject = strSubject '发信的主题
'MAPIMessages1.MsgNoteText = strNoteText '发信的内容
'MAPIMessages1.AttachmentIndex = 0 '当前附件的索引位置
'MAPIMessages1.AttachmentPathName = fpath + "已评审" + "\" + sbh + ".xls" '附件的路径
'MAPIMessages1.Send '开始发送
'MAPISession1.SignOff '可以算成关闭吧
Call send_Click
End If
End Sub
Private Sub send_Click()
Dim lCount As Long
Dim lCtr As Long
Dim t!
Set poSendMail = New clsSendMail
With poSendMail
.SMTPHostValidation = VALIDATE_HOST_DNS
.EmailAddressValidation = VALIDATE_SYNTAX
.Delimiter = ";"
End With
Screen.MousePointer = vbHourglass
'======================================================
'GetPrivateProfileInt "邮件清单", "attachment", txtAttach.Text, _
App.Path + "\config.ini"
'======================================================
With poSendMail
' **************************************************************************
' Set the basic properties common to all messages to be sent
' **************************************************************************
.SMTPHost = GetPrivateStringValue("邮件清单", "SMTPHost", _
App.Path + "\config.ini") ' Required the fist time, optional thereafter
.From = GetPrivateStringValue("邮件清单", "senderemail", _
App.Path + "\config.ini") ' Required the fist time, optional thereafter
.FromDisplayName = GetPrivateStringValue("邮件清单", "sendername", _
App.Path + "\config.ini") ' Optional, saved after first use
.Message = GetPrivateStringValue("邮件清单", "message", _
App.Path + "\config.ini") ' Optional
.Attachment = fpath + "已评审" + "\" + sbh + ".xls" '附件的路径 ' Optional, separate multiple entries with delimiter character
' get the message count and set the timer
lCount = 1
If lCount = 0 Then Exit Sub
t! = Timer
' **************************************************************************
' Send the mail in a loop. In a real app you would need to load a new
' recipient from a file or database each pass through the loop.
' **************************************************************************
' send method only (normal button)
' **************************************************************************
' For lCtr = 1 To lCount
' .Recipient = "lqg_k@163.com"
' .RecipientDisplayName = "lqg_k"
' .Subject = "zhuti"
' .Send
' Next
' .Disconnect
'***********************************************************
' connect, send, disconnect methods (bulk send button)
'***********************************************************
If .Connect Then
For lCtr = 1 To lCount
.Recipient = GetPrivateStringValue("邮件清单", "recipientemail", _
App.Path + "\config.ini")
.RecipientDisplayName = GetPrivateStringValue("邮件清单", "recipientname", _
App.Path + "\config.ini")
.Subject = sbh + GetPrivateStringValue("邮件清单", "subject", _
App.Path + "\config.ini") '发信的主题
.Send
Next
.Disconnect
End If
End With
Set poSendMail = Nothing
Screen.MousePointer = vbDefault
MsgBox "发送成功!", vbInformation, "提示"
End Sub
范例界面如下:
需要引用 SmtpClient 和 MailMessage类生成邮件,然后发送即可。
如果非要通过exchange server,可以用微软提供的sdk写入vb.net的代码中。
你好,这个容易,你只需要把你的那个程序打包(或者叫压宿打包)以附件的形式通过QQ或者其他电子邮件发送给你的朋友即可。等他调试完了后也会以同样方式发给你,你收到后只需要解压就可以了。如果你不知道如何压宿和解压的话,请给我发邮件,我给你传如何操作的视频(我自己录制)。
贴上来是其中一个贴子,其他的内容在参考资料的网址里
Visual Basic 6中发送邮件的新方法
用VB6编写发送邮件的程序,有多种E-mail组件可供选择,如MAPIMessages、IIS4.0附带的CDONTS(NTS Collaboration Data Objects)以及许多第三方厂商开发的Email软件等。本文介绍用CDONTS开发VB下的邮件程序方法。
1. 确认已安装SMTP服务器
首先,必须确认在IIS服务器上已安装SMTP服务器,这是安装Option Pack时被缺省安装的选项。如果SMTP服务器已安装,在System32目录下会存在一个名为cdonts.dll的文件。
2. 最简单的邮件发送程序
以下是一个最简单的邮件发送程序,它由me@hotmail.net向abc@263.net发出一封标题为“Title”、内容为“Hello”的E-mail:
Private Sub cmdSendMail_Click()
Dim objMail as Object
Set objMail=CreateObject("CDFONTS.DLL")
ObjMail.Send "me@hotmail.net ", "abc@263.net","Title","Hello"
Set objMail=nothing
End Sub
3. 发送邮件附件
如果有附加的文件需要随同邮件传送,可以使用CDONTS的AttachFile方法:
Private Sub cmdSendMail_Click()
Dim objMail as Object
Set objMail=CreateObject("CDFONTS.DLL")
With ObjMail
.From= "me@hotmail.net "
.To= "abc@263.net"
.Subject="Title"
.Body="Hello"
.AttachFile "c:\document\ sample.doc","sample.doc"
.Send
End With
Set objMail=nothing
End Sub
4. CDONTS组件常用属性和方法
CDONTS组件常用的属性和方法列举如下:
属性:
Version:返回CDONTS组件的版本号
MailFormat:邮件格式,1-普通文本类型;0-MIME类型
Cc:设置一个或多个参阅的邮件地址
From:邮件发送者的地址
To :邮件接受者的地址
Subject:标题
Body:内容
BodyFormat:内容格式,1-普通文本;0-超文本
方法:
AttachFile:附加一个文件
AttachURL:附加一个地址
Send:发送邮件
5. 发送超文本格式的E-mail
你一定见到过许多使用超文本格式的E-mail,其中不但可以有图片、声音,甚至还可以嵌入动画。如果给你的朋友也发送一封这样的邮件,一定会带给他(她)意外的惊喜,因为这用一般的邮件发送程序是无能为力的。以下使用CDONTS组件发送一个HTML格式的邮件,其中包含有一幅名为sample.gif的图片,程序如下:
Private Sub cmdSendMail_Click()
Dim objMail as Object
Set objMail=CreateObject("CDFONTS.DLL")
Dim strHTML as String
StrHTML=""
StrHTML= StrHTML+""
StrHTML = StrHTML +"
用CDONTS发送Email的例子"
StrHTML= StrHTML+"
"
StrHTML= StrHTML+"
以上例子嵌入了图片sample.gif
"
StrHTML= StrHTML+""
With ObjMail
.From= "me@hotmail.net "
.To= "abc@263.net"
.Subject="Title"
.Body=strHTML
.AttachURL "c:\mydata\sample.gif","sample.gif"
.BodyFormat=0
.EmailFormat=0
.Send
End With
Set objMail=nothing
End Sub
到这里,相信大家一定发现SMTP邮件处理的一个缺陷了。SMTP服务器接收你的输出消息,但并不做发送者名字和地址的验证,这本是由SMTP的异步发送机制所决定的,但有人可能别有用心地用它来假扮别人发送邮件!本文强烈建议各位切勿轻易试用,一旦让ISP知道你的行径,你的帐号极可能会被立即删除。
'创建发件连接,根据你的发送邮箱的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 = "邮件正文内容"
'添加收件人,如果有多个,可以多次添加
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