winforms 如何在VB中为Azure信息保护自动分类Outlook电子邮件敏感性,网?

shyt4zoc  于 2023-05-01  发布在  其他
关注(0)|答案(2)|浏览(149)

我正在使用www.example开发一个windows www.example.com ,尝试通过outlook发送电子邮件。我的代码运行正常,但一旦它到达send()行,就会弹出Azure Information Protection窗口,以选择电子邮件敏感度(Public、Confidential、...等),所以直到用户选择才发送电子邮件。
我尝试了(OutlookMessage.敏感性=展望。Ol敏感性。olNormal),但仍然需要有人从Azure弹出窗口中选择分类,完整代码如下所示。..

Dim OutlookMessage As outlook.MailItem 
Dim AppOutlook As New outlook.Application 
Try
 OutlookMessage = AppOutlook.CreateItem(outlook.OlItemType.olMailItem)
 Dim Recipents As outlook.Recipients = OutlookMessage.Recipients Recipents.Add("myemail@hotmail.com") 
 OutlookMessage.Subject = "Sending through Outlook" 
 OutlookMessage.Body = "Testing outlook Mail" 
 OutlookMessage.BodyFormat = outlook.OlBodyFormat.olFormatHTML
 OutlookMessage.Sensitivity = outlook.OlSensitivity.olNormal 
 OutlookMessage.Send() 
Catch ex As Exception 
 MessageBox.Show("Mail could not be sent") 'if you dont want this message, simply delete this line 
Finally 
 OutlookMessage = Nothing 
 AppOutlook = Nothing 
End Try
11dmarpk

11dmarpk1#

希望代码使用服务帐户运行,请执行以下操作
1.在限定范围的AIP策略中添加上述服务帐户
1.在限定范围的策略中设置默认标签
这样做不会触发弹出窗口,因为默认标签已经应用(我希望)。
注意:您可以使用AIp策略的advanced settings为Outlook和其他MS应用程序设置不同的默认标签

gfttwv5a

gfttwv5a2#

我已经找到了最好的方法来分类电子邮件而不得到弹出通过VBA代码。用户需要遵循以下步骤:
1.创建具有敏感度级别(私人、公共、机密、普通)的电子邮件模板。
打开Outlook =〉CTRL + N =〉Classify sensitivity =〉File =〉保存AS template(Private.oft)=〉保存。
1.一旦模板准备就绪,您可以使用以下代码发送电子邮件,而不会弹出

Sub SendEmailWithoutPopupClassification()
Dim origEmail As Outlook.MailItem 'To refer new outlook email
Dim replyEmail As Outlook.MailItem 'To refer new outlook email
Dim EmailApp As Outlook.Application 'To refer to outlook application
Dim Source As String

Set replyEmail = Outlook.Application.CreateItemFromTemplate("C:\Users\akash\AppData\Roaming\Microsoft\Templates\Test Email.oft") replyEmail.To = "akashgupta.softs@gmail.com"
replyEmail.Subject = "Test Email From Excel VBA" 
replyEmail.HTMLBody = "Hi," & vbNewLine & vbNewLine & "This is my first email from Excel"

Source = "C:\Users\guptakag\SampleAttachmentIfany.xlsb"

replyEmail.Attachments.Add Source
replyEmail.Send

End Sub

1.使用按钮从Excel调用上述函数。

相关问题