add new email account to outlook2007 programmatically using c# - c#

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 )

Related

Outlook 2010 add-in/extension to white-list attachments?

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.

How to configure Cached Exchange mode for Outlook using C#?

I am working on a tool that needs to configure the Cached Exchange mode for outlook. I tried meddling with the registry but it seems like its not a good way to go about it, since in Outlook 2010 it is very unpredictable. Now, I am looking into either using Outlook Primary Interop Assembly or the Group Policy Assembly. I can find ways to read the current configuration but unable to set them. Is there a way to do it? Are there any other ways to accomplish the same?

check for existence of office.interop assemblies

I'm working on a c# project where I get input from Office documents, and right now I'm using MS Office for it. This simply means the MS Office interop components have to be present on the user's PC for this to work.
However, I might implement OpenOffice.org into it too eventually, and in that case I want my application to be automatically able to choose which program to use to process files based on what is available.
Is there any simple way to test whether certain references I made in my project are actually available on the computer that is running the program? I really don't want to release different binaries based on Office types.
What about a simple try catch block?
If the DLL is not present on the system then the most basic call will return a meaningful error. In that particular case you can load another class that will handle a different word or speadsheet processor

Reading mails from outlook programmatically using C#

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...

How to prepopulate an Outlook MailItem and avoiding a com Exception from the object model guard

I work for a company that develops a CRM tool and offers integration with MS Office(2003 & 2007) from windows XP to 7. (I'm working using Win7)
My task is to call an Outlook instance (using C#) from this CRM tool when the user wants to send an email and prepopulate with data of the CRM tool (email, recipient, etc..)
All of this already works just fine.
The problem I'm having is that Outlook's "object model guard" is throwing com Exception
(Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)))
the moment I try to read a protected value from the mailItem (such as mail.bodyHTML).
Example Snippet:
using MSOutlook = Microsoft.Office.Interop.Outlook;
//untrusted Instance
_outlook = new MSOutlook.Application();
MSOutlook.MailItem mail = (MSOutlook.MailItem)_outlook.CreateItem(MSOutlook.OlItemType.olMailItem);
//this where the Exception occurs
string outlookStdHTMLBody = mail.HTMLBody;
I've done quite a bit of reading and know that my Outlook Instance (derived by using new Application) is considered untrusted and therefore the "omg" kicks in.
I do have a workaround for development:
I'm running VS2010 as Administrator and if I run Outlook as Administrator as well - all is good. I suppose this is due to them having the same integrity levels(high) and the UAC(?) is not complaining. But that just ain't the way to go for deployment.
Now the question is:
Is there a way to obtain a trusted instance of Outlook so that I can avoid this exception?
I've already read that when developing an Office Add-In using VSTO one can obtain a trusted Instance from the OnComplete event and/or using "ThisAddin"
But I "merely" want to start an outlook instance and preopulate it, and do not want to develop an Add-In since this is not the requirement.
And to make it clear - I have no problem with pop ups informing the user that outlook is being accessed - I just want to get rid of the exception!
So how can I get around this problem using code?
Any help is highly appreciated!
Thomas
Take a look at Dimitry's Redemption Lib, It was designed to do exacly this.
Well,
I've already spent way too much time and energy on this question so I think I came up with a pragmatic workaround for my particular case - but no real solution!
The problem is apparently due to the programms running at different integrity levels (Outlook = medium, VS2010 = admin or high). Office runs by default on a medium level and so will my future application once deployed. So there shouldn't be any trouble, since if the CRM and Outlook run at the same level, there's no problem.
For development I just let em both run on high, or medium (starting my compiled files from the debug folder).
In any other case a Messagebox warning is shown informing the user of the different integrity levels that cause an exception and prevent access.
At the code level, when I try to read any (by Outlook) prepolutated, protected properties and the object model guard raises the exception, I just catch it and use default values instead.
Why I had to read them in first place is currently beyond me - but so were the specs which were handed to me.
Anyway thanks for reading and if I ever come up with a solution I'll be sure to psot it - until then keep in mind that a pragmatic solution is better then none!
Happy Father's Day everyone!

Categories

Resources