原文章:
调用Outlook发送邮件[Access软件网]
http://www.accessoft.com/article-show.asp?id=17362
要实现这个功能,我们需要使用Outlook的一个方法:Display。
先给原函数增加一个可选参数 EmailPreview ,默认 False,然后通过 EmailPreview 来控制是否进入预览界面。
函数:
Public Function OutlookSendEmail(ToAddress As String, Subject As String, Body As String, Optional Attachment As String = "", Optional CC As String = "", Optional BCC As String = "", Optional EmailPreview As Boolean = False)
Dim objOutlook As outlook.Application
Dim objMail As MailItem
Set objOutlook = New outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = ToAddress '收件人
.CC = CC '抄送
.BCC = BCC '密件抄送
.Subject = Subject '标题
.Body = Body '正文
If Attachment <> "" Then .Attachments.Add Attachment '附件
If EmailPreview Then
.Display '显示
Else
.Send '发送
End If
End With
MsgBox "发送成功!"
End Function
调用方法:
OutlookSendEmail "收件人邮箱地址","邮件标题","邮件正文","附件(可选)","抄送(可选)","密件抄送(可选)","预览(可选)"
提问(下篇文章解答):
怎么可以在发送邮件的时候,自动附带有超链接、图片、格式的签名?
如图所示: