My goal is to create an extension for Outlook 2010 to white-list allowed attachments by their file extension and also enable it to "look into" ZIP attachments to check file extensions inside.
I'm very familiar with coding in C# in the Visual Studio IDE, but I've never done an Outlook (or Office) extension before.
So my first question to people who might have tried it -- is it possible to do what I want?
And if yes, can you suggest any resources on how to program such an extension?
PS. I'm coding this specifically for our office set-up, i.e. Windows 7 (client) with Outlook 2010 as email program.
If you are using Microsoft Exchange, this is controlled by the exchange server, not by the Outlook client. I'm not sure what the restrictions are for other email systems, but I would guess there is usually a server-side filter that would return a "non-deliverable" error if a blocked attachment is found.
You could get around this with your add-in by changing the extension of a blocked file type to something else and adding some sort of note as a .txt attachment or within the message text saying what the original message was. I'll leave design work to you, but it might be nice to have a list where you can add/remove extensions that should be changed to something else.
Once you've set your computer up with the prerequisites for development, I would start here: https://msdn.microsoft.com/en-us/library/bb386094.aspx and browse through the child pages of that topic. I would also take a look at https://msdn.microsoft.com/en-us/library/cc668191.aspx (one of the child pages) for a complete walkthrough.
The Outlook object model doesn't provide anything for filtering attachments. Moreover, it doesn't allow to open attachments on the fly. You need to save the attachment as a file on the disk, see SaveAsFile for more information. Then you can open it for exploring as a regular file. Also you may consider using a low-level API (Extended MAPI) for opening attachments as array of bytes.
Related
Imagine a mail server that supports attachments in the range of 400-500 mb. Or Imagine a mail that is 30 mb, but has 10 attachments - if we have to download the whole message each time we wish to remove an attachment from it, that's a 300 mb overhead the GC has to take care of.
IMailFolder.GetMessage is nice, but in cases such as these, it's better to use IMailFolder.Fetch.
Sadly though, I don't see a way in which I can add something to an IMessageSummary (in my case, I'd like to add an attachment, or remove an attachment) and "modify" that message I fetched on the server with my change. That's possible by using ImailFolder.Append(MimeMessage), but as the method signature implies, it requires a MimeMessage, which IMessageSummary is not.
Any ideas?
First, let me clear something up:
The information contained on the IMessageSummary is really meant as read-only metadata about the message. The Body and Attachments properties aren't the full MIME parts, they are just metadata about the MIME parts.
Okay, now that that is out of the way:
The base IMAP protocol does not support doing what you want to do. What you would need to do is download the full message, make changes to the message, append the modified message to the IMAP folder, and then delete the old (original) message.
If the server supports the REPLACE extension, then the APPEND + STORE FLAGS \Deleted + EXPUNGE operations can be made atomic, but the gist of it is still the same in that you'd still need to download the message, modify it, and then upload it back to the server.
I think that covers your previous stackoverflow question here: How to move an attachment from one e-mail to another using MailKit/MimeKit?
(including it for context in case anyone reading this is interested in knowing the solution for that)
But this question is different from the old question in that you are asking if there is a more efficient way of adding or removing MIME parts from a message on the IMAP server without having to download it locally first.
There just so happens to be an IMAP extension called CATENATE that kind of allows for this.
Unfortunately, I have not yet had time to implement this extension in MailKit and I'm not sure if it's really worth doing because so few IMAP servers actually support this extension anyway.
That said, I'd be willing to add this extension to my TODO list if there is value in adding it.
You can check if your server supports this extension by checking:
if (client.Capabilities.HasFlag (ImapCapabilities.Catenate)) {
Console.WriteLine ("Yes! The IMAP server supports the CATENATE extension!");
}
If not (and I suspect it doesn't), then your only option is to download the message, remove parts, and then re-upload.
Have read a few variants of this, but nothing exactly addresses the problem I have.
I'm part of a data migration team, and one of our tasks is migrating existing documents from one environment to another, and once migrated, maintain any existing hyperlinks within.
For relatively new documents (Office 2007+), this is no problem. I've had a look at DocX by Cathal Coffey; NPOI which apparently is unstable and not recommended for use - or at least the part I need anyway; GemBox and others, and while they work perfectly for newer documents, none of them can deal with opening/modifying documents from Word '97. Thankfully documents created under Win 3.1 or Word for Windows 2 are out of scope.
I realise that these documents are very old and not supported any more and as such, may pose security risks, I also realise that they should have been maintained and brought up to date by their respective teams but for whatever reason, they haven't been and now it's my job to try and come up with a way to do this.
Using the oldest version of the COM object I have available (Microsoft Office 14.0 Object Library, Version 8.5.0.0) I run into problems with making changes to Trust Settings, Registry changes etc. Doing all of this leads to its own problems such as having to open the document in protected mode when I need to make changes to it, and besides, when this gets deployed, I won't have access to the Trust Center nor to the Registry. Examining the document in memory shows the Hyperlink collection but won't let me see the details like I can in DocX for example.
Is there way to do this or am I going back saying these docs are too old, unsupported and the relevant teams need to do a better job of maintaining their documents? Thought about maybe trying to read the doc in as HTML then examining any href tags, thoughts? Can I get my hands on older versions of the Microsft DLLs, and even if I can, will they be compatible with VS 2015? 3rd party libraries are an option (Gem, DocX etc.) but something like Aspose Documents is out of the question as the license is $1000.
Nice to have - something that will work without needing Office installed would be truly the stuff of dreams.
Thanks everyone.
The simplest and fastest way would be to convert the documents to Open XML format. This can be easily done on the command line (replace the path with the path where winword.exe is installed on your machine):
"C:\Program Files\Microsoft Office\Office15\wordconv.exe" -oice -nme <input file> <output file>
where and need to be fully qualified path names.
The command can be easily applied to multiple documents using for:
for %F in (*.doc) do "C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme "%F" "%Fx"
Once the files are converted you can modify the documents by editing the raw XML inside the zip package or by using Microsoft's Open XML SDK.
I am trying to integrate my IM-client, written in C#, with MS Outlook 2013. I would like Outlook to receive presence information from my IM-client. First shot was to use this instruction.
It worked well in the beginning (Outlook get my interface, check for version and features, abilities to start conversation), but in the chapter "Retrieving contact presence" I've got a difference. Outlook didn't call "GetContactInformation" as described. It isn't work for neither interface returned for version "15.0.0.0" nor "14.0.0.0".
I've tried to turn on logging using OfficePresenceLogging, but it appeared to be available only for previous versions of MS Outlook. So, I used this technique, which gave me binary file "Microsoft Support Engineer has the tools to analyze".
Since I use Windows 8.1, LorParser 2.2 unable to read this file, and TraceRpt.exe is only able to give me metadata (like time or Process ID). The important part of the log is hidden beneath BinaryEventData field. I could translate those hexes to ascii and see something like a methods names and garbage.
I wonder if someone could advise me something:
Is it possible to read Office 2013 logs to troubleshoot my IM integration?
Is there any hints that could I check to find a problem?
I come up with some solution, so I want to write down an answer. I hope it can be useful for someone.
Unfortunately I failed to read Outlook 2013 logs in both Windows 8.1 and Windows 7. The only solution I've found: test the application with Office 2010 (it uses text logs). You can find instructions how to turn on logs at the end of this article.
In my case the first error I've got was:
"CMsoProviderOCom::HrEnsureContactAndGroupManager !failed! Line: 3998 hr = 0x80040200"
It seems Outlook reject all further information if something went wrong at the beginning of the integration with IM.
Check your application returns all correct values for the methods Outlook uses.
Check you've implemented all events, it seems impossible to find lack of them with debugger.
Take a look at Lync SDK. It has the similar interface (Microsoft.Lync.Model) and it's documentation looks more complete.
In my case I just forgot to mark couple of my classes with [ComSourceInterfaces()].
I am trying to create a program that reads my mail from Microsoft Outlook so that I can move them into different folders based on thier contents. I am using Microsoft.Office.Interop.Outlook 12.0, which works fine with Outlook 2007.
How do I handle scenario where another user uses Outlook 2010?
Do you need to use C#? If you don't need to use C#, you can open one of the messages that you need to move and click on "add rule". There you can define rules to, for example, move all mail from your boss into a folder called work. I don't see why you need to use C#. It would be very difficult to do that in C# except simulating mouse movements...
All I was wondering if there was a way to run a program and add a spesific email account (with all the correct port settings and whatnot) to outlook2007
I have several users in the feild that seem incapable of doing this themselfs or even doing it with me walking them threw it over the phone
I would love to just email them a program and they run it and it just configures it for them.
How to do this from .net (c#)?
From managed code ther is no way via the OOM but redemption has a Profman lib.
I would also say check out the Office Customization Tool in the 2007 Office system (Ok thats not via code :) but may be simpler for you to use )