A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook Macro to Forward Multiple Emails



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 6th 06, 11:33 PM posted to microsoft.public.outlook.program_vba
Jim
external usenet poster
 
Posts: 230
Default Outlook Macro to Forward Multiple Emails

Our workgroup has been requested to send emails a specific subject that
are saved in our personal folders in Outlook 2003 to an email address set up
for document retention purposes. Each individual email must be forwarded
separately.

I have attempted to use this macro I found, but I can't get it to send more
than one email at a time. Is there a way to change it to send numerous
highlighted emails (i.e., 10 at a time) from Outlook?

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
End Select

Set objApp = Nothing
End Function
Sub ADDASSPAM()
Dim myOlApp As New Outlook.Application
Dim myItem, myForward As Object

Set myItem = GetCurrentItem()
Set myForward = myItem.Forward


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

Set myItem = Nothing
Set myForward = Nothing

End Sub

Ads
  #2  
Old December 7th 06, 12:04 AM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Macro to Forward Multiple Emails

Selection is a collection. You must iterate it instead of always using 1 as
the index.

I'd restructure the code to loop Selection and put everything in one Sub.

Never use a new Outlook.Application object in an Outlook macro. Use the
intrinsic Application object.

For Each oItem In Application.ActiveExplorer.Selection
'now you can forward every one of the items that's selected.
Next

--
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
...
Our workgroup has been requested to send emails a specific subject
that
are saved in our personal folders in Outlook 2003 to an email address set
up
for document retention purposes. Each individual email must be forwarded
separately.

I have attempted to use this macro I found, but I can't get it to send
more
than one email at a time. Is there a way to change it to send numerous
highlighted emails (i.e., 10 at a time) from Outlook?

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
End Select

Set objApp = Nothing
End Function
Sub ADDASSPAM()
Dim myOlApp As New Outlook.Application
Dim myItem, myForward As Object

Set myItem = GetCurrentItem()
Set myForward = myItem.Forward


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

Set myItem = Nothing
Set myForward = Nothing

End Sub


  #3  
Old December 7th 06, 06:13 PM posted to microsoft.public.outlook.program_vba
Jim
external usenet poster
 
Posts: 230
Default Outlook Macro to Forward Multiple Emails

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?

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

Selection is a collection. You must iterate it instead of always using 1 as
the index.

I'd restructure the code to loop Selection and put everything in one Sub.

Never use a new Outlook.Application object in an Outlook macro. Use the
intrinsic Application object.

For Each oItem In Application.ActiveExplorer.Selection
'now you can forward every one of the items that's selected.
Next

--
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
...
Our workgroup has been requested to send emails a specific subject
that
are saved in our personal folders in Outlook 2003 to an email address set
up
for document retention purposes. Each individual email must be forwarded
separately.

I have attempted to use this macro I found, but I can't get it to send
more
than one email at a time. Is there a way to change it to send numerous
highlighted emails (i.e., 10 at a time) from Outlook?

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
End Select

Set objApp = Nothing
End Function
Sub ADDASSPAM()
Dim myOlApp As New Outlook.Application
Dim myItem, myForward As Object

Set myItem = GetCurrentItem()
Set myForward = myItem.Forward


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

Set myItem = Nothing
Set myForward = Nothing

End Sub



  #4  
Old December 7th 06, 09:48 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Macro to Forward Multiple Emails

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?


  #5  
Old December 12th 06, 09: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?



  #6  
Old December 12th 06, 09:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Outlook Macro to Forward Multiple Emails

If this is VBA running in the Outlook VBA project in Outlook 2003 you should
not get the security prompts. However, for your options with the security
see http://www.outlookcode.com/d/sec.htm

--
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
...
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.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to setup a rule to forward rule in Outlook (xp or 2003) to forward emails from a certain domain when app isnt running? KingCronos Outlook - General Queries 7 November 15th 06 12:22 PM
Outlook Macro To Forward Emails [email protected] Outlook - General Queries 3 September 23rd 06 09:08 PM
forward macro newbies Outlook and VBA 4 August 16th 06 01:33 AM
outlook forward macro Phil Best Outlook and VBA 6 July 18th 06 01:45 PM
macro to forward Dan Outlook and VBA 8 February 23rd 06 08:22 PM


All times are GMT +1. The time now is 03:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.