首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在发送邮件时解决弹出分类问题?

如何在发送邮件时解决弹出分类问题?
EN

Stack Overflow用户
提问于 2018-03-06 18:48:51
回答 1查看 3.9K关注 0票数 1

我使用VBA发送电子邮件。每封电子邮件都会弹出一个分类,需要手动设置。我正在尝试在代码中解决这个问题。

我找到了一个发送电子邮件的代码:Mail a message with outlook via VBA

在修复了一些东西之后,下面的代码就可以正常工作了。

代码语言:javascript
复制
Sub sendEmail()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2016
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Set OutApp = CreateObject("Outlook.Application")
    
    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        Set OutMail = OutApp.CreateItem(0)
        On Error Resume Next
        With OutMail
            .To = cell.Value
            .Subject = "Reminder"
            .Body = "Dear " & Cells(cell.Row, "A").Value _
              & vbNewLine & vbNewLine & _
              "Please Finish your course " & Cells(cell.Row, "C") & _
              " before expiry date."
            .Send  'Or use Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

问题是,在从列表中向例如10个人发送电子邮件后,我需要单击10次分类弹出窗口。

我发现了这个:How to save workbook and handle TITUS (or any other document classification add-in) popup?

我在.Send之前尝试过.EnableEvents = False。我不确定这对我是否有用。

如何在我的案例中使用它?是否可以禁用它,解决它,甚至在代码中设置一个分类?

EN

回答 1

Stack Overflow用户

发布于 2018-12-20 03:32:25

有一种解决方法,但您必须在Outlook Developer本身中执行此操作。您可以在Outlook中设置触发宏的事件处理程序。因此,在这种情况下,Outlook可以监视使用特定主题行(例如)创建的邮件,这将触发下面的脚本,从而绕过TITUS。

代码语言:javascript
复制
'Sets Titus Mail settings and sends mail
    With AOMailMsg
        objMsg.ItemProperties.Add("ABCDE.Registered To", olText) = "My Companies"

        objMsg.ItemProperties.Add("ABCDE.Classification", olText) = "Internal"
        objMsg.UserProperties.Add("ABCDE.Registered To", olText) = "My Companies"
        objMsg.UserProperties.Add("ABCDE.Classification", olText) = "Internal"
        objMsg.UserProperties.Add("TITUSAutomatedClassification", olText) = _
             "TLPropertyRoot=ABCDE;.Registered To=My Companies;.Classification=Internal;"
        objMsg.Send
    End With
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49128979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档