View Single Post
  #5  
Old December 12th 06, 08:14 PM posted to microsoft.public.outlook.program_vba
Jim
external usenet poster
 
Posts: 230
Default Outlook Macro to Forward Multiple Emails

Thanks Ken. The macro will now work on multiple emails, but I get a message
box for each and every email that says "A program is trying to automatically
send an emial on your behalf. Do you want to allow this?" and has yes/no
buttons. Hitting "yes" for each email defeats the purpose of the macro. Is
there a way to bypass this message? I don't have admin privileges on either
my machine or the exchange server.

"Ken Slovak - [MVP - Outlook]" wrote:

The code has to be restructured, there's really no good place for that loop
as it currently is structured.

Something like this, where GetCurrentItem is the macro you call:

Sub GetCurrentItem()
Dim oItem As Object

On Error Resume Next

Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
For Each oItem In Application.ActiveExplorer.Selection
'now you can forward every one of the items that's selected.
call ADDASSPAM(oItem)
Next
Case "Inspector"
call ADDASSPAM(ActiveInspector.CurrentItem)
Case Else
End Select

Set oItem = Nothing
End Sub

Sub ADDASSPAM(myItem As Object)
Dim myForward As Object

Set myForward = myItem.Forward

myForward.To = "
Set myForward.SaveSentMessageFolder = _
Application.GetNamespace("MAPI"). _
GetDefaultFolder(olFolderDeletedItems)

myForward.Send

Set myForward = Nothing
End Sub


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Jim" wrote in message
news
Thanks for the quick response. Unfortunately, my VBA skills are
rusty/lacking, so where would the "For Each oItem In
Application.ActiveExplorer.Selection" go in the code?



Ads