How can I change colours in Outlook via VSTO? - c#

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.

Related

Outlook custom MailTip on MailItem

Is it possible to modify an Outlook MailItem object to display a Mailtip with custom text? It doesn't look to be possible using the OOM, how about at the MAPI layer, i.e. using Redemption?
If not possible, is there some way to achieve a similar effect? (e.g. Ribbon XML, etc.)
mailtip example
The best you can do is add a category - it will be displayed in the same area.
The tip itself comes from Exchange server as a result of an EWS call. There is no way to display custom data there.
I am not sure if you are still interested in possibilities to display MailTips based on your own rules with your own texts: There is an Outlook add-in called MailScout allowing that (mailscout-app.com). Kind regards

Outlook VSTO C# get all MailItems headers without iterate one by one and get property

Is there a way to get all headers of all MailItems in folder fast, without iteration and get property of each item,
I know there is folder GetTable method but it supports only first 255 chars of string, so it's not good for headers.
Nope. The Outlook object model doesn't provide anything for that. What is your final goal?
Note, you can run a secondary thread in Outlook where you can use a low-level code for gathering the required information. Extended MAPI supports multiuthreading. Or you may consider using any third-party wrappers around that API (for example, Redemption). Be aware, you shouldn't use OOM from secondary threads. Outlook will raise an exception if it detects such calls. See multi process in outlook addin for more informaiton.

How to set classification of an email automatically?

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.

C# parse outlook calendar item

I am writing an application that employees in our business use to capture their timesheets. My colleague that helps with the development got a brilliant idea to add a feature that an employee can drag and drop their calendar entries from Microsoft Outlook and a timesheet entry will be created with the correct details.
It was easy to create the drag and drop feature but only the meeting title and location get exposed. The interpretation code is this:
Object item = (object)e.Data.GetData(typeof(System.String));
textBox1.Text = item.ToString();
The result I get is this:
Time Sheet parameters and data capturing strategy (East Meeting Room 3)
I have tested it by dragging it into Microsoft Word and then there just appears an Outlook item on which you can double click to open the event.
Is there some way I can access the meeting's start and end time in my application?
Edit: I have tested Office Interop libraries and it works like a charm, though I would like to avoid the use of that. People in our office have different versions of Microsoft Office and I could not be sure that it would work on every PC.

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.

Categories