Home

AIP VBA for Outlook / Emails ("apply automatically a label to the Email")

%3CLINGO-SUB%20id%3D%22lingo-sub-764630%22%20slang%3D%22en-US%22%3ERe%3A%20AIP%20PowerShell%20scripting%20for%20Outlook%20%2F%20Emails%20(%22apply%20automatically%20a%20label%20to%20the%20Email%26amp%3Bqu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-764630%22%20slang%3D%22en-US%22%3E%3CP%3EUpdate%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20(very%20simplified)%20code%20snipet%20that%20the%20user%20is%20running%20on%20the%20client%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%24Outlook%20%3D%20New-Object%20-ComObject%20Outlook.Application%3CBR%20%2F%3E%24Mail%20%3D%20%24Outlook.CreateItem(0)%3C%2FP%3E%3CP%3E%24Mail.To%20%3D%20'%3CTEST%3E'%3C%2FTEST%3E%3C%2FP%3E%3CP%3E%24Mail.Subject%20%3D%20'AIP%20label%20test%20mail'%3C%2FP%3E%3CP%3E%24body%20%3D%20'%26lt%3B%E2%80%A6%26gt%3B'%3C%2FP%3E%3CP%3E%24Mail.HTMLBody%20%3D%20%24body%3C%2FP%3E%3CP%3E%24Mail.Send()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20see%20any%20chance%20where%20I%20can%20add%20my%20classification%20label%20in%20here%3F%20%3A-%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETGIF!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBR%3C%2FP%3E%3CP%3EMartin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-764305%22%20slang%3D%22en-US%22%3EAIP%20VBA%20for%20Outlook%20%2F%20Emails%20(%22apply%20automatically%20a%20label%20to%20the%20Email%22)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-764305%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20AIP%20community%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20modified%20my%20conversation%20a%20bit%20(removed%20the%20PowerShell)%20as%20we%20have%20issues%20with%20automation%20of%20Outlook%20in%20relation%20to%20set%20labels%20at%20all.%20Is%20there%20any%20chance%20to%20use%20the%20Outlook%20object%20to%20add%20header%20information%20to%20an%20Email%20send%20by%20Outlook%3F%20Where%20are%20the%20programmers%3F%20%3A-%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Foutlook.application%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Foutlook.application%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20far%20I%20haven't%20seen%20any%20method%20etc.%20to%20add%20static%20label%20information%20(properties)%20to%20the%20Email%20header.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBR%2C%3C%2FP%3E%3CP%3EMartin%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E--------------------------------------------------------%20old%20content%20%3D%26gt%3B%3C%2FP%3E%3CP%3EWe%20have%20many%20users%20in%20our%20company%20using%20automation%20scripts%20to%20get%20things%20done.%20Currently%20we%20investigating%20a%20lot%20of%20Excel%20macros%20and%20we'd%20like%20to%20provide%20a%20Sub%2Ffunction%20to%20everyone%20to%20be%20able%20to%20set%20a%20label%20in%20advance%20(before%20the%20macro%20%22hit%20the%20save%20or%20close%20button%22).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20now%20we%20encountered%2C%20that%20some%20colleagues%20also%20using%20PowerShell%20scripts%20to%20control%20Outlook%20and%20send%20automated%20Emails.%20The%20script%20stops%20working%20after%20we%20have%20enabled%20AIP%20for%20those%20users.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20haven't%20seen%20cmdlets%20from%20the%20AIP%20PS%20Module%20for%20Emails%2C%20%22only%22%20for%20files.%20I%20am%20waiting%20for%20the%20code%20right%20now.%20But%20as%20mentioned%20before%2C%20PS%20controls%20the%20local%20Outlook%20installation%20to%20send%20an%20Email.%20A%20possible%20workaround%20would%20be%20to%20use%20%22Send-MailMessage%22%20or%20%22New-Object%20System.Net.Mail.MailMessage%22%2C%20but%20might%20have%20to%20many%20limitations%20for%20the%20user.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20using%20the%20latest%20Office%20ProPlus%20version.%20Do%20you%20have%20any%20further%20information%2C%20%3CSPAN%3Erecommendation%2C%3C%2FSPAN%3Esuggestion%20or%20even%20a%20solution%3F%20%3CSPAN%3EMuch%20appreciated.%3C%2FSPAN%3E%20Pre-define%20a%20label%20or%20send%20it%20without%20a%20label%20would%20be%20both%20fine.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20a%20nice%20Friday%2C%3C%2FP%3E%3CP%3EMartin%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-764305%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EInformation%20Protection%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
MartinZoller
Occasional Contributor

Dear AIP community,

 

I modified my conversation a bit (removed the PowerShell) as we have issues with automation of Outlook in relation to set labels at all. Is there any chance to use the Outlook object to add header information to an Email send by Outlook? Where are the programmers? :-]

 

https://docs.microsoft.com/en-us/office/vba/api/outlook.application

 

So far I haven't seen any method etc. to add static label information (properties) to the Email header.

 

BR,

Martin

 

-------------------------------------------------------- old content =>

We have many users in our company using automation scripts to get things done. Currently we investigating a lot of Excel macros and we'd like to provide a Sub/function to everyone to be able to set a label in advance (before the macro "hit the save or close button").

 

But now we encountered, that some colleagues also using PowerShell scripts to control Outlook and send automated Emails. The script stops working after we have enabled AIP for those users. 

 

I haven't seen cmdlets from the AIP PS Module for Emails, "only" for files. I am waiting for the code right now. But as mentioned before, PS controls the local Outlook installation to send an Email. A possible workaround would be to use "Send-MailMessage" or "New-Object System.Net.Mail.MailMessage", but might have to many limitations for the user.

 

We are using the latest Office ProPlus version. Do you have any further information, recommendation, suggestion or even a solution? Much appreciated. Pre-define a label or send it without a label would be both fine. 

 

Have a nice Friday,

Martin

1 Reply

Update:

 

Here is the (very simplified) code snipet that the user is running on the client:

 


$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)

$Mail.To = '<test@contoso.com>'

$Mail.Subject = 'AIP label test mail'

$body = '<…>'

$Mail.HTMLBody = $body

$Mail.Send()

 

Do you see any chance where I can add my classification label in here? :-]

 

TGIF!

 

BR

Martin

Related Conversations