Help with 'MailItem' object of WordMail Inspector

  • Thread starter Thread starter gspence1
  • Start date Start date
G

gspence1

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!
 
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.
 
Back
Top