Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook VBA: Forward Selected Inbox Msg 1

Status
Not open for further replies.

sjpistolesi

Programmer
Jun 6, 2002
71
US
Env: Outlook 2000 / Windows 2000

I've figured out how to generate a "new" message and modify it for my user, to save her repeated/redundant steps of establing specific option criteria in a new message she wishes to send multiple times in a single workday.

Now, she asks me to do the same thing, but instead generate a "Forward" message for a selected message in her Inbox folder list, and still modify the same criteria.

The purpose is to open a "FWD" type message saving her the extra steps of opening a selected message first and then clicking on Forward to generate such a message.

Question: Using VBA, how can I generate a Forward'd message to be forwarded by my user, for a selected item in that user's Inbox?

In this context, the user will fill in the Addressee fields ("To:" and "Cc:") herself, in the message I generate. (Her addressing varies widely, based on the contents of the inbound message, so she accepts the need to perform this function manually.)

Thanks,
Sandy
 
From Outlook2000 Help: Hope this helps to at least get you started. Have a great day!

Forward Method Example

This Visual Basic for Applications example uses the GetDefaultFolder method to return the MAPIFolder object that represents the default Inbox folder for the current user. It then uses the Forward method to retrieve the first message in the default Inbox folder and forward it to Laura Jennings. The Add method is used to add Laura Jennings to the Recipients collection and the Send method sends the item to all recipients. It is assumed that the name will resolve unambiguously in the Address Book.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myForward = myFolder.Items(1).Forward
myForward.Recipients.Add "Laura Jennings"
myForward.Send

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myForward = myFolder.Items(1).Forward
myForward.Recipients.Add "Laura Jennings"
myForward.Send
 
SBendBuckeye,

Yes, I noted those from HELP; but those examples assume I know which item in the inbox. I need to detect the one the user selected, then work with that one only.

But thanks for taking the time to research for me.

Sandy
 
Assuming there is just one mail item selected, you can use this one:

application.Explorers(1).selection(1)

Rob
[flowerface]
 
Your tip was just the clue I needed.

I adjusted, played with, and then adapted it to my own function/style and now the users are happy.

Thanks for helping to break down that barrier.

Have a very happy Monday, Sandy
 
Now cometh a problem ... our environment was upgraded and had security patches applied.

First, the VBA didn't run any more.

Second, I applied my digital signature, which enabled the code to run, as being from an approved source. But, what I cannot seem to turn off is the additional alert dialog that appears saying, in effect that an application is trying to activate a verb on your behalf, do you want it to run?

When the user clicks on "yes," s/he must then establish the length of time it can run (max 10 minutes), then click on "OK."

So, the VBA runs once more, but these additional, disconcerting dialog is irritating to a user, who simply wants to do his/her job. Does anyone know how to deactivate these additional "clicks"??

Sandy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top