Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I've tried everything I can think of and cannot figure this out. Basically, I'm making an Outlook 2010 Add-In that makes adjustments to incoming HTML formatted emails for the purposes of making them more Accessible to visually-impaired users (visually impaired users in particular.)

Everything works fine, except that when my Add-In runs, it actually attempts to modify the original email no matter what I try, which Exchange connected Outlook doesn't like at all and rejects. What I want to do is display my modified email message with all of the goodies (reply, reply-all, BCC, etc., just like you would normally use Outlook) without modifying the original message...that is, I only want to display my modified message, not modify the stored message or add a new message.

Such as:
C#
if (selObject is Outlook.MailItem)
  {
      Outlook.MailItem mailItem = (selObject as Outlook.MailItem);
      Outlook.MailItem accessible_mail_item = mailItem;
      ...rest of my code...
      accessible_mail_item.Display(false);
  }

The problem I have is, "accessible_mail_item" is not a copy of "mailItem"...it's a pointer to it. How can I make a copy/clone of this non-Serializable/Clonable Object? I've tried various "Deep Clone" functions out there, but they all give me the same errors about "not being serializable" or whatever.

Any help will be much appreciated!!!!!!!!

Thanks!
Kendell
Posted
Updated 25-Sep-12 18:52pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Sep-12 23:36pm    
First of all, why do you need cloning, exactly? Why are you sure you need it? And now, you "manually" clone the email object (or something), what prevents you from cloning mailItem?

What you need is called "deep cloning" and usually not supported. It's clear how to make it for your own types, but if you deal with predefined types, you need to do it "manually". Or avoid it.

--SA
Kendell 26-Sep-12 0:08am    
Fair questions. I am using a Microsoft pre-defined type, and have no way around that. I _think_ that I need cloning because I need a MailItem Object that is not connected in any way to the original object but is identical in every other way. If I simply use the built-in "Copy" method, it creates a duplicate message in the Outlook folder, which I don't want. In the end, I need the user to be presented with my modified version of the message, yet be able to interact with it as if it were the original message (aka reply, forward, etc., using the Outlook 2010 interface.) The problem with "Deep Cloning," even using manual methods as far as I've been able to find, is that "Outlook.MailItem" does not implement either IClonable or ISerializable, therefore making the strategies I've found useless. I'm hoping that you folks could suggest another strategy. My only other work-around is a huge pain in the you-know-what, and not exactly what I want to do. Worst case, I'll do that.
Kendell 26-Sep-12 0:12am    
Perhaps another option would be prevent Outlook from entering my "Copy" into the folder, but I can't seem to find a way to do that.

1 solution

Try DeepCopy() in fastJSON[^] or fastBinaryJSON[^] as they don't require the object to be serializable or clonable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900