简体   繁体   English

在VBA中不同发件人之间切换的最简单方法是什么?

[英]What's the easiest way to switch between different senders in VBA?

Namely, I'm talking about MAPIFolder, MailItem, and Recipient object types. 即,我在谈论MAPIFolder,MailItem和收件人对象类型。

-------------------Additional Info------------------------------------------- - - - - - - - - - -附加信息 - - - - - - - - - - - - - - - --------------

Here's some objects I have: 这是我的一些物品:

Dim w As Outlook.Application
Dim wInbox As Outlook.MAPIFolder
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

I'm looking for .SendUsingAccount property, for example below from this article : 我正在寻找.SendUsingAccount属性,例如下面的这篇文章

Public Sub New_Mail()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem

For Each oAccount In Application.Session.Accounts
   If oAccount = "Name_of_Default_Account" Then
      Set oMail = Application.CreateItem(olMailItem)
      oMail.SendUsingAccount = oAccount
      oMail.Display
   End If
Next
End Sub

If you second mailbox is called "Other Person" then you could try this to reference the Inbox that belongs to it (as distinct from the default Inbox) 如果您将第二个邮箱称为“其他人”,则可以尝试使用该邮箱来引用属于它的收件箱(与默认收件箱不同)

Dim objOl As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objFolder As Outlook.MAPIFolder
Set objOl = New Outlook.Application
Set objNS = objOl.GetNamespace("MAPI")
Set objFolder = objNS.Folders("Other Person")
Set objFolder = objFolder.Folders("Inbox")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM