VBA code for the equivalent of Resend this Message

H

Herb Martin

Seeking VBA code for the equivalent of menu Actions->Resend this Message

Or even the name of the method if their is such (and the object
probably.)

Is there are really good REFERENCE -- preferably online
and searchable -- for all the common VBA in Outlook (the help
is terrible -- probably the worst help Microsoft provides,
which is GENERALLY quite good) ?

The object browser is ok, but not the full answer.
 
M

Michael Bauer

Hi Herb,

this sample simulates a click on that button:


Dim oCmd as Office.CommandBarButton
Set oCmd=Application.ActiveInspector.CommandBars(,3165)
oCmd.Execute
 
H

Herb Martin

Thank you.
Dim oCmd as Office.CommandBarButton
Set oCmd=Application.ActiveInspector.CommandBars(,3165)

First argument is not "optional" -- get this as an error:

"Argument not optional"

Outlook 2003 if it matters.
oCmd.Execute

Imposing a bit further on your good will: I need to feed this the
"To" address and loop over an entire folder (or selection of messages)
in a folder.

Looping over the selected folder or messages doesn't seem that hard,
even if I must create an inspector for each item, but would you know
of a way to feed the (standard) address to the subsequent form....?

It would likely be ugly to open a thousand (or even 100 inspectors),
must less having to close them all, but it would serve my purpose
of using this to send email (largely unmodified) to a pair of Ham
and Spam reporting addresses.
 
M

Michael Bauer

Set oCmd=Application.ActiveInspector.CommandBars(,3165)
First argument is not "optional" -- get this as an error:

Yes, of course, I forgot to write the method :) It should be:

Set oCmd=Application.ActiveInspector.CommandBars.FindControl(,3165)

Do you want to send sent items again? Then you don´t need that command.
Just loop through the folder Items or Selection, copy each MailItem and
send it, sample:

Sub SendAgain()
' Send items again
Dim obj As Object
Dim oFld As Outlook.MAPIFolder

Set oFld = Application.Session.PickFolder
For Each obj In oFld.Items
If TypeOf obj Is Outlook.MailItem Then
obj.Copy.Send
End If
Next
End Sub
 
H

Herb Martin

Michael Bauer said:
Yes, of course, I forgot to write the method :) It should be:
Set oCmd=Application.ActiveInspector.CommandBars.FindControl(,3165)

Thanks, that works and explains why I couldn't parse it out from
CommandBars directly.
Do you want to send sent items again? Then you don´t need that command.

No, I am trying to do almost precisely what resend (the menu
item) does, that is, to send the email from a "spam" folder to
a spam (or "ham" folder to ham) classification system on my
mail server.

I need to do as little change to the original mail as possible and
have been trying to obtain the RFC822 original form of the emails
to just bulk load them (zip or whatever) but this "resend" seems
to be close enough as it changes the headers VERY little (probably
in an acceptable way) and does not change the message or subject
at all.

Doing this message by message is ok, but way to slow. I want
my users to be able to just select a folder or group of messages and
without having to input the destination, or agree to the "you do not
appear to be the original sender" popup, just have them sent to a
known address on the email server.

Say, (e-mail address removed)

Looping through is the relatively easy part -- getting the effect of
either resend or saving the 'original' message to disk as a separate
file is the hard part (for me) so far.

Thanks for the help -- I would love to hear if you have other ideas....

BTW, my SpamAssassin installation can autolearn these message as
either Spam or Ham if I can get this to work.
Just loop through the folder Items or Selection, copy each MailItem and
send it, sample:

Sub SendAgain()
 
M

Michael Bauer

Hi Herb,

using OutlookSpy (www.dimastr.com) it seems that the main difference
between the received message and that one after clicking Resend is that
the latter one is without any RECEIVED* (and RCVD*) properties. So maybe
you could copy the received message, delete the mentioned properties,
replace the recipient, and the send the message to the new recipient.
 

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