How to set classification of an email automatically? - c#

I have the following powershell script:
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "receiver#host.com"
$Mail.Subject = "Hello"
$Mail.Body ="World"
$Mail.Send()
But when I execute it I have to select classification of the email manually: there appears a TITUS pop up with a the "Select Classification" title select box containing the following items: Public, For Internal Use Only and Private. I have to select an item and click "OK", after that the email is sent.
The script is supposed to be a job that gets run on schedule, so I don't want to interact with the script at all.
I have already walked through the whole msdn page of MailItem but I didn't come across anything similar to Classificaiton. What did I miss?
I am not an administrator of the server, so I don't have access to change anything.
PS: I selected the C# tag just because C# has the same API to interact with Outlook

Firstly, Outlook, just like any other Office app, is not designed to be used in unattended scenarios. It can and will display modal prompts out of the blue.
Secondly, to send a message, you can use straight SMTP, EWS, Extended MAPI (C++ or Delphi only), or Redemption (I am its author - its RDO family of objects wraps Extended MAPI and can be accessed for many language).
In your particular case, it sure looks like a custom third-party addin displaying a dialog box.

The mail object is not able to set the classification of the email object. If you pipe the object to Get-Member, you will see that there is no changeable property for the classification and/or a method to change it. You can find this by running the following command:
$Mail | Get-Member
Additionally, if you look at the list of properties there is not one that looks related to classification.
$Mail | Format-List
This blog post will probably help you, but it seems more complex than the solution you're looking for. This one utilizes Exchange instead of the Outlook client.

Related

How can I change colours in Outlook via VSTO?

Good Morning,
Since a few days, I'm searching for an opportunity to change colours in Outlook by VSTO (Visual Studio Tools for Office - C#).
I would like to change the colour of the recipient, which I write down when I would like to send an e-mail.
Is that even possible?
I don't find anything on the web about that, but it would be the best solution for my project.
The Outlook extensibility model doesn't provide anything for customizing the Outlook UI, i.e. changing colors of the recipients.
The best what you could do is to use the ContactItem.Categories property which allows setting a string representing the categories assigned to the Outlook item.
Categories is a delimited string of category names that have been assigned to an Outlook item. This property uses the character specified in the value name, sList, under HKEY_CURRENT_USER\Control Panel\International in the Windows registry, as the delimiter for multiple categories.

Outlook VSTO Addin

I'm currently working on add in to outlook but face a problem my requirement is to add feature that is similar to spell checking (program will underline some of the text in real time). Is that even possible in vsto ? any material is appreciated i've searched for answer online - without any success
The integration you need would not be with VSTO or the Outlook Object Model, but rather mainly with the Word Object Model (WOM). Outlook users Word to render HTML formatted messages and provides access to the email as if it is a Word document, via the Inspector.WordEditor property which returns a Word.Document object.
So you can use WOM to format the body content as you see fit. However, there are no real-time events for hooking into changes of the message body as they occur. You will need to use either timers or low-level keyboard hooks to capture the changes that the user is making.

Have Outlook search for all conversations with certain email

I wish to have my app initiate a search in Outlook for all mail correspondence with a certain person. I am trying to use the Microsoft.Office.Interop.Outlook API, but I am having problems figuring out exactly how to perform this search or even if what I am attempting to do is possible.
So I do not want to extract the data from Outlook, I want to remote control Outlook to perform the search there.
That can be done with conversations.
MailItem mi = ....
Conversation c = mi.GetConversation();
c.GetRootItems() --> thats the whole correspondence

Outlook VSTO adding tracking pixel

I'm adding an img tracking pixel to items that have embedded content using my outlook addin which allows me to track when the person has open the email (pretty standard practice)
I do this by adding an image tag right before the closing body tag upon the send event.
The problem is, outlook then calls the url three times (twice with a method of "OPTIONS" and once with "GET"), this defeats the whole purpose of the tracking pixel because it triggers the event on send.
Does anyone know why outlook makes these requests, or how to get around this?
I see two possibilities:
Either Outlook or Exchange Server is checking the eMail content before sending it
OR
Outlook is configured to “When an HTML message contains pictures located on the Internet, send a copy of the pictures instead of the reference to their location” - for changing that setting in Outlook 2007/2010 via Registry see http://www.msoutlook.info/question/72
BTW: the two OPTIONS calls let me believe that Outlook is somehow checking the server of the linked image for WebDAV and/or Frontpage extensions...

Is there a way to automatically re-send an email according to certain rules with Outlook 2007 and MS Exchange?

I am looking for a solution to the following problem:
My manager wants to automatically send a second message when he sends an email to X and there is no response in two days. If there is no further response in 2 more days, send another message.
Before I start building anything, I wonder if there is already a product/solution that does that? Can anybody recommend an already existing tool?
We use MS Exchange and he uses Outlook 2007.
Auto Follow Up is a tool I've used in the past for this specific purpose. Also, always check www.slipstick.com for listings of Outlook/Exchange add-ins - they seem to be the best source (disclaimer: I have no affiliation with that site or any of its add-ins)
It's not an existing solution, but in case you don't get any answers:
You can use Exchange Web Services to do this: pointing it at his Sent Items folder. So this is basically what you would do:
Use SyncFolderItems against his Sent Items, say every 1 hour. The first time you do this use null as the SyncState, thereafter use the last SyncState the server sent you.
Write them to a SQL table: { ItemId NVARCHAR(MAX), ChangeKey NVARCHAR(MAX), MessageID NVARCHAR(MAX), Sent DATETIME }. MessageID would be the Message-ID header from the message.
Run a query (say once a day) that selects the rows where the Sent value is more than 2 days ago.
Use GetItem to retrieve the original mail and resend (first clearing/deleting Message-ID) it using SendItem.
Delete the selected rows.
These items will land up in the Sent Items folder and will be picked up by your application (as they are actually new mails); and re-processed in 2 days.
Use SyncFolderItems against his Inbox, again maybe every hour (maybe immediately after the first operation against Sent Items). Keep a unique SyncState for this operation.
Grab the In-Reply-To header. Delete any rows with a maching MessageID.
Grab the References header; and split it into a list. Delete any rows with a matching MessageID.
Would this solve your problem:
http://www.followupthen.com/
Perhaps not exactly what you want and it isn't integrated into Outlook.
I don't think you will find exactly what you want. This is functionality which belongs to a CRM, not to email software.
Having said that, the Getting Things Done Outlook Add-In will get you in that direction. It won't automatically send a follow up mail, but it can take care of a notification so you send it yourself. (but this plugin is not free - $75 - you have to decide yourself if that's worth it)
With the GTD add-in you can send a mail, and select the option "Send and Action". After pressing send mail, you can select the action "#Waiting For", and press ok. Now it will create an outlook task, with the subject and contents of the email you sent automatically filled. You can set all the task properties, like end date and notification time.
After two days at the notification time, you get a (default) outlook popup, where you can open the task. With one click you can open the corresponding email and use reply or forward to send your followup. You can create a new task or modify the existing task for the next followup.
If you receive a reply in the mean time, and open the mail, you can use the "related task" button to find the corresponding task to mark it as complete. It also adds buttons like defer and delegate to your mail.
There is a 30-day trial. I am not connected to netcentrics, but I have bought and use this plugin.
Have you looked into automating Outlook using Visual Basic for Applications? If you aren't familiar with VBA, or if the thought of writing VBA gives you nightmares (I've had a few), then you might find some example VBA code on the web that accomplishes something similar to what you are trying to do, and then you could just tweak it. I know you said that you wanted an existing tool, but I thought I would throw this out there as a sort of last resort. It's not ideal, but I'm pretty sure it would solve your problem.

Categories