【问题标题】:System administrator unable to send olBCC mail系统管理员无法发送 olBCC 邮件
【发布时间】:2020-06-23 07:47:53
【问题描述】:

我有一个自定义 Outlook 约会,我想在发送我的约会邀请时自动从该约会中密件抄送一封邮件。

Function Item_Send()
    Set oMsg = Application.ActiveInspector.CurrentItem 
    With oMsg 
        Set objRecip = Item.Recipients.Add("MyEmail@mail.com")
        objRecip.Type = olBCC
        objRecip.Resolve 
    End With
    Set oMsg = Nothing 
End Function

似乎一切正常 - 我的电子邮件已作为密件抄送附加,并且约会已成功发送。

但是,在我的收件箱中,我收到一封无法访问密件抄送邮件的邮件。

您的邮件未到达部分或全部预期收件人。

主题:
发送时间:18/06/2020 14:49

无法联系到以下收件人:

MyEmail 于 2020 年 6 月 18 日 14:49 'MyEmail@mail.com' 于 2020 年 6 月 18 日 14:49 无法发送此消息。请稍后再尝试发送消息,或联系您的网络管理员。


管理员的诊断信息:


错误是 [0x80070057-0x00000000-0x00000000]。提交消息失败: 消息 id(23),失败枚举(7),HResult(0x80070057),EC(-2147024809)。

为什么会出现这个错误?我的邮件没有错。

【问题讨论】:

  • 也许this 有帮助...
  • @PeterSchneider 这是一个完全不同的问题。

标签: vba outlook


【解决方案1】:

尚不清楚Item 对象的来源。

首先,MeetingItem 收件人的Type 属性可以是以下OlMeetingRecipientType 常量之一:olOptionalolOrganizerolRequiredolResource。如果您想发送密件抄送,我建议您创建一个新邮件项目并将属性复制到新项目。


无论如何,Resolve 方法返回一个布尔值,如果对象已解析,则该值为 true;否则为假。例如,这就是您需要检查的方式:

Sub AssignTask() 
 Dim myItem As Outlook.TaskItem
 Dim myDelegate As Outlook.Recipient

 Set MyItem = Application.CreateItem(olTaskItem) 

 MyItem.Assign 

 Set myDelegate = MyItem.Recipients.Add("Eugene Astafiev") 

 myDelegate.Resolve 

 If myDelegate.Resolved Then 

   myItem.Subject = "Prepare Agenda For Meeting" 

   myItem.DueDate = Now + 30 

   myItem.Display 

   myItem.Send 

 End If 

End Sub

请注意,ItemSend 事件处理程序接受两个参数。例如,VB.NET 中的以下代码在我的机器上就像一个魅力:

Imports System.Runtime.InteropServices
' ...
Private Sub OnItemSend(Item As System.Object, ByRef Cancel As Boolean) _
                       Handles Application.ItemSend
    Dim recipient As Outlook.Recipient = Nothing
    Dim recipients As Outlook.Recipients = Nothing    
    Dim mail As Outlook.MailItem = TryCast(Item, Outlook.MailItem)
    If Not IsNothing(mail) Then
        Dim addToSubject As String = " !IMPORTANT"
        Dim addToBody As String = "Sent from my Outlook 2010"
        If Not mail.Subject.Contains(addToSubject) Then
            mail.Subject += addToSubject
        End If
        If Not mail.Body.EndsWith(addToBody) Then
            mail.Body += addToBody
        End If
        recipients = mail.Recipients
        recipient = recipients.Add("Eugene Astafiev")
        recipient.Type = Outlook.OlMailRecipientType.olBCC
        recipient.Resolve()
        If Not IsNothing(recipient) Then Marshal.ReleaseComObject(recipient)
        If Not IsNothing(recipients) Then Marshal.ReleaseComObject(recipients)
    End If
End Sub

在用户单击 Outlook 中的“发送”按钮后(在检查器窗口关闭之前)或调用 Outlook 项目的“发送”方法时,立即触发此事件。 ItemSend 事件为程序员提供了两个参数:

  • Item 对象 – 将要发送的 Outlook 项目。它可以由AppointmentItemMailItemMeetingItemMobileItemSharingItemTaskItem 类表示。
  • Cancel 参数 - 允许您取消在 Outlook 中的发送。默认值为假。如果您在事件处理程序中将 Cancel 参数设置为 true,则会取消发送过程并向用户显示检查器窗口。

How To: Change an Outlook e-mail message before sending using C# or VB.NET 文章中了解更多信息。

【讨论】:

    猜你喜欢
    • 2020-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 2020-02-20
    • 2010-11-27
    • 2021-06-14
    • 1970-01-01
    相关资源
    最近更新 更多