[英]How to change “from” field?
I inherited an Access program that sends emails from my email address.我继承了从我的电子邮件地址发送电子邮件的 Access 程序。
I want to send from a group email address, say Reporting@zzzz.com.我想从群组电子邮件地址发送,例如 Reporting@zzzz.com。
There are two email boxes, mine and the group email.有两个邮箱,我的邮箱和群邮箱。
I changed the default email account in Outlook to use the group email, but it deposits the emails into my draft folder instead of Reporting@zzzz.com's draft folder.我更改了 Outlook 中的默认电子邮件帐户以使用组电子邮件,但它将电子邮件存放到我的草稿文件夹中,而不是 Reporting@zzzz.com 的草稿文件夹中。
The code uses this to make an email:该代码使用它来制作电子邮件:
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
With olMail
.Subject = stSubject
olMail
does not appear to have a .From
field. olMail
不会出现有.From
现场。
How can I change the from field or get the macro to recognize the 2nd email box (which I have full rights to)?如何更改发件人字段或让宏识别第二个邮箱(我拥有全部权限)?
Is that a delegate Exchange mailbox?那是委托 Exchange 邮箱吗? Try to set
MailItem.SentOnBehalfOfName
property.尝试设置
MailItem.SentOnBehalfOfName
属性。
I have dealt with this in a non-delegate situation -- multiple accounts (Exchange, IMAP).我在非委托情况下处理过这个问题——多个帐户(Exchange、IMAP)。 Any MailItem I created was coming from my Exchange account, even though the IMAP account was set as the default to send from.
我创建的任何邮件项目都来自我的 Exchange 帐户,即使 IMAP 帐户被设置为默认发送。 If you declare this sub:
如果您声明此子项:
Sub SetSendingAcct(ByRef mi As Object, strAddress As String)
' mi as Outlook.MailItem
Dim acct As Object 'Outlook.Account
For Each acct In appOutlook.Session.Accounts
If acct.SmtpAddress = strAddress Then
Set mi.SendUsingAccount = acct
mi.Display
mi.Save ' This makes the change visible in the UI
Exit For
End If
Next acct
End Sub
Then you would change your code to:然后您将代码更改为:
Dim strSMTP = "Reporting@zzzz.com"
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
SetSendingAcct olMail, strSMTP
With olMail
.Subject = stSubject
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.