简体   繁体   中英

Excel VBA: How to send email to group in outlook?

I am looking to auto send an email from excel vba to outlook 2013.

I am able to send the email to individuals and pass the TITUS classification, however I still get the below error when I send to a group email .

How do I select " send anyway " in VBA?

在此处输入图片说明

Below is the code I have to send the email:

Dim AOMSOutlook As Object
Dim AOMailMsg As Object
Set AOMSOutlook = CreateObject("Outlook.Application")
Dim objUserProperty As Object
Dim OStrTITUS As String
Dim lStrInternal As String
Set AOMailMsg = AOMSOutlook.CreateItem(0)

Set objUserProperty = AOMailMsg.UserProperties.Add("TITUSAutomatedClassification", 1)
objUserProperty.Value = "TLPropertyRoot=ABCDE;Classification=Internal;Registered to:My Companies;"
With AOMailMsg
        .To = "mygroup@list.company.com"
        .Subject = "my subject"
        .Attachments.Add Img
        .HTMLBody = "my text"            
        .Save
        .Send
End With
Set AOMailMsg = Nothing
Set objUserProperty = Nothing
Set AOMSOutlook = Nothing
Set lOMailMsg = Nothing
Set objUserProperty = Nothing
Set lOMSOutlook = Nothing

Any help greatly appreciated!

Thanks to @MattCremeens was able to resolve by adding:

    .display
    SendKeys "{DOWN}{DOWN}{ENTER}", True 'set classification
    SendKeys "{ENTER}",True 'send to group
    .send
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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