用Excel vba调用Outlook的用户名,也就是已发信箱中的邮件发件人sender
展开全部
参考下面的VBA代码
Sub Send_Email()
Dim i As Integer
Dim MyOutlookApp As Outlook.Application
Dim MyFolder As Outlook.MAPIFolder
Dim MyNewMail As Outlook.MailItem
Dim MyAttachments As Outlook.Attachments '附件
Set MyOutlookApp = New Outlook.Application
Set MyFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "我的邮件文件夹 ")
Set MyNewMail = MyOutlookApp.CreateItem(olMailItem)
With MyNewMail
.To = "YourFridentMail@sina.com " '目标邮件地址
.Cc="aaa@qq.com"
.Subject = "test " '标题
.HTMLBody = " This is red "
.AlternateRecipientAllowed = True '此邮件可转发
.AutoForwarded = True '此邮件允许自动转发
.DeleteAfterSubmit = False '发送后保留副本
'发送之后移动到指定文件夹
.SaveSentMessageFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "备份文件夹 ")
.ReadReceiptRequested = True '要求收件人回执
'SaveSentMessageFolder
End With
'附件
Set MyAttachments = MyNewMail.Attachments
MyAttachments.Add "c:\win\abc.txt ", olByValue
MyNewMail.Save '保存
MyNewMail.Send '发送
MyFolder.Display '显示office outlook
End Sub
Sub Send_Email()
Dim i As Integer
Dim MyOutlookApp As Outlook.Application
Dim MyFolder As Outlook.MAPIFolder
Dim MyNewMail As Outlook.MailItem
Dim MyAttachments As Outlook.Attachments '附件
Set MyOutlookApp = New Outlook.Application
Set MyFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "我的邮件文件夹 ")
Set MyNewMail = MyOutlookApp.CreateItem(olMailItem)
With MyNewMail
.To = "YourFridentMail@sina.com " '目标邮件地址
.Cc="aaa@qq.com"
.Subject = "test " '标题
.HTMLBody = " This is red "
.AlternateRecipientAllowed = True '此邮件可转发
.AutoForwarded = True '此邮件允许自动转发
.DeleteAfterSubmit = False '发送后保留副本
'发送之后移动到指定文件夹
.SaveSentMessageFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "备份文件夹 ")
.ReadReceiptRequested = True '要求收件人回执
'SaveSentMessageFolder
End With
'附件
Set MyAttachments = MyNewMail.Attachments
MyAttachments.Add "c:\win\abc.txt ", olByValue
MyNewMail.Save '保存
MyNewMail.Send '发送
MyFolder.Display '显示office outlook
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询