Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: clone
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:
  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 25-Sep-12 16:28pm
Kendell305
Edited 25-Sep-12 18:52pm
v2
Comments
Sergey Alexandrovich Kryukov at 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 at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 OriginalGriff 6,696
1 Sergey Alexandrovich Kryukov 6,675
2 CPallini 5,315
3 George Jonsson 3,584
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100