![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
I have created an Outlook addin that was originally designed to do some
processing on a selected mail item in an explorer and it works great. One of the things it does is a "SaveAs" to html format and then send the html version of the email to a web service. I now have a requirement to be able to do the same processing on a NEW email from within the inspector. The requirement is that I add a new button that does this processing AND sends the mail item so the user just has to click one button. My first attempt was to get the CurrentItem of the Inspector and pass it to my class that handles all of the processing of the mail item. After the processing was done, I was going to call the Send method of the item to send it and be done. However, I am finding now that my class designed to process mail items doesnt work when the mailitem points to the currentitem of an inspector. One problem is that when I attempt to do the SaveAs to HTML format, I get RTF garbage at the top which I'm assuming is coming from the word editor. Another thing my class does is save the email attachments and send them to a web service. However, the attachments are not saving correctly. It seems reasonable that there are many differences between a MailItem coming from an explorer and the CurrentItem coming from the WordMail editor. I dont wish to rewrite my class to work on both items. It seems the simplest solution would be to go ahead and send the new mail first, and then pass that mailitem to my class afterwards. I tried this, however I get the error that "The Item was Moved". Any suggestion on how I can get a reference to the email either before or after it is sent so that the MailItem object looks and behaves just like the MailItem objects from an Explorer? I also tried calling "Save" to save the mail to drafts and then access the currentitem but had the same problems. Here's the sample of code that works. Dim selObject As Object = Me.ActiveExplorer.Selection.Item(1) If (TypeOf selObject Is Outlook.MailItem) Then Dim wizard As New AREMIS(CType(selObject, Outlook.MailItem)) wizard.ShowDialog() End If Here's the sample of code that doesnt work. Dim mi As Outlook.MailItem = CType(Me.ActiveInspector.CurrentItem, Outlook.MailItem) 'mi.Send() 'tried sending it first but got error object was moved 'mi.Save() 'tried saving it first but didnt make a difference Dim wizard As New AREMIS(mi) wizard.ShowDialog() Thanks in advance for your help! |
#2
|
|||
|
|||
![]()
Do you call MailItem.Save before you call SaveAs?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool wrote in message oups.com... I have created an Outlook addin that was originally designed to do some processing on a selected mail item in an explorer and it works great. One of the things it does is a "SaveAs" to html format and then send the html version of the email to a web service. I now have a requirement to be able to do the same processing on a NEW email from within the inspector. The requirement is that I add a new button that does this processing AND sends the mail item so the user just has to click one button. My first attempt was to get the CurrentItem of the Inspector and pass it to my class that handles all of the processing of the mail item. After the processing was done, I was going to call the Send method of the item to send it and be done. However, I am finding now that my class designed to process mail items doesnt work when the mailitem points to the currentitem of an inspector. One problem is that when I attempt to do the SaveAs to HTML format, I get RTF garbage at the top which I'm assuming is coming from the word editor. Another thing my class does is save the email attachments and send them to a web service. However, the attachments are not saving correctly. It seems reasonable that there are many differences between a MailItem coming from an explorer and the CurrentItem coming from the WordMail editor. I dont wish to rewrite my class to work on both items. It seems the simplest solution would be to go ahead and send the new mail first, and then pass that mailitem to my class afterwards. I tried this, however I get the error that "The Item was Moved". Any suggestion on how I can get a reference to the email either before or after it is sent so that the MailItem object looks and behaves just like the MailItem objects from an Explorer? I also tried calling "Save" to save the mail to drafts and then access the currentitem but had the same problems. Here's the sample of code that works. Dim selObject As Object = Me.ActiveExplorer.Selection.Item(1) If (TypeOf selObject Is Outlook.MailItem) Then Dim wizard As New AREMIS(CType(selObject, Outlook.MailItem)) wizard.ShowDialog() End If Here's the sample of code that doesnt work. Dim mi As Outlook.MailItem = CType(Me.ActiveInspector.CurrentItem, Outlook.MailItem) 'mi.Send() 'tried sending it first but got error object was moved 'mi.Save() 'tried saving it first but didnt make a difference Dim wizard As New AREMIS(mi) wizard.ShowDialog() Thanks in advance for your help! |
#3
|
|||
|
|||
![]()
Yes, that was one of the things I tried, as you can see the commented
mi.Save in the code above. I think I have narrowed it down now so that the only descrepency I have between a new email and existing email is that when you call "SaveAs" on an item in the WordMail editor you get a bunch of RTF junk at the top of the msg. If I could get rid of this, my problem would be solved. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Read body of MailItem ? | Trey Shaffer | Outlook and VBA | 1 | March 18th 06 08:56 PM |
how to detect programmatically if some code is runing in wordmail | Herve cadieu | Outlook and VBA | 5 | March 14th 06 04:36 PM |
How can I create a MailItem that displays like a received MailItem ? | Clive | Outlook - Using Forms | 0 | February 27th 06 05:14 PM |
Help! Inspector.Close is fired before Inspector.Activate handler finishes | Sergey Anchipolevsky | Add-ins for Outlook | 8 | February 9th 06 10:51 AM |
dialog comes up when trying to access mailItem | Neo | Add-ins for Outlook | 3 | January 16th 06 10:56 PM |