Outlook Add-In (VB.NET)

N

Nicholas Then

I am writing an outlook add-in that is a simple button using the Office XP interops. The user clicks it and the message forwards to a specified mailbox and then the origonal email is deleted. See below...

Dim oEmailMessage As Outlook.MailItem = CType(m_olApp.ActiveInspector.CurrentItem, Outlook.MailItem)

Dim oNewEmailMessage As Outlook.MailItem = oEmailMessage.Forward
oNewEmailMessage.DeleteAfterSubmit = True
oNewEmailMessage.To = "(e-mail address removed)"
oNewEmailMessage.Send()
oEmailMessage.Delete()

The add-in is used by our spam services so that employees can submit emails that our filters do not catch. Our spam software will then check this specified box and by using Bayesian analysis will add the patterns to its database. Pretty simple....however I have noticed some problems....when, lets say, I click on the add-in button and the message is forwarded to the server, the origonal history is now in the body of the message such as...

--------------------------------------------------------------------------------
From: Some User [mailto:[email protected]]
Sent: Monday, June 14, 2004 3:00 PM
To: Another User
Subject: RE: Blah Blah Blah

Is there a way that I can get the above text out of my email? It is messing up the filtering because company addresses are now getting added to the spam database...

I have tried oNewEmailMessage.Body = oEmailMessage.Body which does copy the body, but the formatting is way off, and the .ClearConversationIndex does not seem to remove anything. So basically is there a way that I can forward an email but not have it the text shown above to prevent my filters from logging data that should not be logged?

Finally I have placed this in another post but I don't know if it has posted or not... When I delete my origonal message using oEmailMessage.Delete() Outlook puts the message into the deleted items folder. Can I get outlook to permanently delete the message?

Thanks in advance...
 
K

Ken Slovak - [MVP - Outlook]

You can make a copy of the message and forward that, you could parse the
Body of the message and remove the added text.

The Delete method of the Outlook object model sends deleted items to the
Deleted Items folder, it does not do "hard deletes". You can do that using
CDO 1.21 to get the item as a CDO Message object and use that Message's
Delete method. That bypasses the Deleted Items folder.

CDO 1.21 isn't supported for .NET use, although people do use it. It is also
an optional installation for Outlook 2000 and later. Alternatives are using
Extended MAPI to do it (hard to learn and can only be coded using C++ or
Delphi) or Redemption (3rd party library located at
www.dimastr.com/redemption).




Nicholas Then said:
I am writing an outlook add-in that is a simple button using the Office XP
interops. The user clicks it and the message forwards to a specified
mailbox and then the origonal email is deleted. See below...
Dim oEmailMessage As Outlook.MailItem =
CType(m_olApp.ActiveInspector.CurrentItem, Outlook.MailItem)
Dim oNewEmailMessage As Outlook.MailItem = oEmailMessage.Forward
oNewEmailMessage.DeleteAfterSubmit = True
oNewEmailMessage.To = "(e-mail address removed)"
oNewEmailMessage.Send()
oEmailMessage.Delete()

The add-in is used by our spam services so that employees can submit
emails that our filters do not catch. Our spam software will then check
this specified box and by using Bayesian analysis will add the patterns to
its database. Pretty simple....however I have noticed some
problems....when, lets say, I click on the add-in button and the message is
forwarded to the server, the origonal history is now in the body of the
message such as...
-------------------------------------------------------------------------- ------
From: Some User [mailto:[email protected]]
Sent: Monday, June 14, 2004 3:00 PM
To: Another User
Subject: RE: Blah Blah Blah

Is there a way that I can get the above text out of my email? It is
messing up the filtering because company addresses are now getting added to
the spam database...
I have tried oNewEmailMessage.Body = oEmailMessage.Body which does copy
the body, but the formatting is way off, and the .ClearConversationIndex
does not seem to remove anything. So basically is there a way that I can
forward an email but not have it the text shown above to prevent my filters
from logging data that should not be logged?
Finally I have placed this in another post but I don't know if it has
posted or not... When I delete my origonal message using
oEmailMessage.Delete() Outlook puts the message into the deleted items
folder. Can I get outlook to permanently delete the message?
 
N

Nicholas Then

Ok...Tried to make a copy of the email and then send that, however... I get this error...

You do not have the permission to send the message on behalf of the specified user.

Is there a way that I can change who the message is from, by putting myself (or the logged in user) as the sender?

Ken Slovak - said:
You can make a copy of the message and forward that, you could parse the
Body of the message and remove the added text.

The Delete method of the Outlook object model sends deleted items to the
Deleted Items folder, it does not do "hard deletes". You can do that using
CDO 1.21 to get the item as a CDO Message object and use that Message's
Delete method. That bypasses the Deleted Items folder.

CDO 1.21 isn't supported for .NET use, although people do use it. It is also
an optional installation for Outlook 2000 and later. Alternatives are using
Extended MAPI to do it (hard to learn and can only be coded using C++ or
Delphi) or Redemption (3rd party library located at
www.dimastr.com/redemption).




Nicholas Then said:
I am writing an outlook add-in that is a simple button using the Office XP
interops. The user clicks it and the message forwards to a specified
mailbox and then the origonal email is deleted. See below...
Dim oEmailMessage As Outlook.MailItem =
CType(m_olApp.ActiveInspector.CurrentItem, Outlook.MailItem)
Dim oNewEmailMessage As Outlook.MailItem = oEmailMessage.Forward
oNewEmailMessage.DeleteAfterSubmit = True
oNewEmailMessage.To = "(e-mail address removed)"
oNewEmailMessage.Send()
oEmailMessage.Delete()

The add-in is used by our spam services so that employees can submit
emails that our filters do not catch. Our spam software will then check
this specified box and by using Bayesian analysis will add the patterns to
its database. Pretty simple....however I have noticed some
problems....when, lets say, I click on the add-in button and the message is
forwarded to the server, the origonal history is now in the body of the
message such as...
-------------------------------------------------------------------------- ------
From: Some User [mailto:[email protected]]
Sent: Monday, June 14, 2004 3:00 PM
To: Another User
Subject: RE: Blah Blah Blah

Is there a way that I can get the above text out of my email? It is
messing up the filtering because company addresses are now getting added to
the spam database...
I have tried oNewEmailMessage.Body = oEmailMessage.Body which does copy
the body, but the formatting is way off, and the .ClearConversationIndex
does not seem to remove anything. So basically is there a way that I can
forward an email but not have it the text shown above to prevent my filters
from logging data that should not be logged?
Finally I have placed this in another post but I don't know if it has
posted or not... When I delete my origonal message using
oEmailMessage.Delete() Outlook puts the message into the deleted items
folder. Can I get outlook to permanently delete the message?
Thanks in advance...
 
K

Ken Slovak - [MVP - Outlook]

Normally a COM addin runs in-process with Outlook and a send action sends as
if the logged in user is manually pressing the Send button. I'm not sure if
VB.NET is screwing that up or something else is wrong.

Other than the security prompt if I use the Outlook object model to send,
which I avoid by using Redemption code, I have never received that message
you cite. Of course I never use .NET languages to develop for Outlook so I'm
not sure how they would be different.

See if maybe any of the information at
http://www.microeye.com/resources/res_outlookvsnet.htm addresses any of the
issues you are seeing.




Nicholas Then said:
Ok...Tried to make a copy of the email and then send that, however... I get this error...

You do not have the permission to send the message on behalf of the specified user.

Is there a way that I can change who the message is from, by putting
myself (or the logged in user) as the sender?
 
S

Sue Mosher [MVP-Outlook]

What's happening is that the From information from the original message is present in the copy. Try setting the MailItem.SendOnBehalfOf property to "" .
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers




Nicholas Then said:
Ok...Tried to make a copy of the email and then send that, however... I get this error...

You do not have the permission to send the message on behalf of the specified user.

Is there a way that I can change who the message is from, by putting myself (or the logged in user) as the sender?

Ken Slovak - said:
You can make a copy of the message and forward that, you could parse the
Body of the message and remove the added text.
Nicholas Then said:
I am writing an outlook add-in that is a simple button using the Office XP
interops. The user clicks it and the message forwards to a specified
mailbox and then the origonal email is deleted. See below...
Dim oEmailMessage As Outlook.MailItem =
CType(m_olApp.ActiveInspector.CurrentItem, Outlook.MailItem)
Dim oNewEmailMessage As Outlook.MailItem = oEmailMessage.Forward
oNewEmailMessage.DeleteAfterSubmit = True
oNewEmailMessage.To = "(e-mail address removed)"
oNewEmailMessage.Send()
oEmailMessage.Delete()

The add-in is used by our spam services so that employees can submit
emails that our filters do not catch. Our spam software will then check
this specified box and by using Bayesian analysis will add the patterns to
its database. Pretty simple....however I have noticed some
problems....when, lets say, I click on the add-in button and the message is
forwarded to the server, the origonal history is now in the body of the
message such as...
-------------------------------------------------------------------------- ------
From: Some User [mailto:[email protected]]
Sent: Monday, June 14, 2004 3:00 PM
To: Another User
Subject: RE: Blah Blah Blah

Is there a way that I can get the above text out of my email? It is
messing up the filtering because company addresses are now getting added to
the spam database...
I have tried oNewEmailMessage.Body = oEmailMessage.Body which does copy
the body, but the formatting is way off, and the .ClearConversationIndex
does not seem to remove anything. So basically is there a way that I can
forward an email but not have it the text shown above to prevent my filters
from logging data that should not be logged?
Finally I have placed this in another post but I don't know if it has
posted or not... When I delete my origonal message using
oEmailMessage.Delete() Outlook puts the message into the deleted items
folder. Can I get outlook to permanently delete the message?
Thanks in advance...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top