Do you call MailItem.Save before you call SaveAs?
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool
<gspence1[ at ]gmail.com> wrote in message news:1147897677.907608.238380[ at ]j33g2000cwa.googlegroups.com...
[Quoted Text] >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! >
|