PDA

View Full Version : Solved: forward multiple emails to one email address as individual emails



aravindhan_3
10-02-2008, 12:28 PM
Hi,

I have around 140 emails in a folder called "Redirected"

I want to forward all those emails to mail.aravindhan@gmail.com individually. If I select all the emails, and click forward all those emails goes as attachment, I do not want to send like that.

All the 140 emails should be sent individually to one email address..

Is this possible in macro...

Arvind

Demosthine
10-02-2008, 03:44 PM
Good Afternoon.

This is very possible. From the Outlook VBE, you'll want to add a new Module for your Function.

Within the module, create a new Function named Forward_Redirect.

You want to define a variable of type MAPIFolder. Set this folder equal to your your Redirected folder.

Next, define a variable of type MailItem and run a For Each <mailitem> In <MAPIFolder>.Items to loop through all of the emails individually.

Inside of each iteration of the loop, you are accessing a single email message. Using that message, run the Forward method. This results in a new email.

Via code, specify the recipient of the forwarded message using the To property and then execute Send.

For some Help File references, check out NewMailEx Event and Forward Method through Outlook's VBE.

This should get you started. If you need more help, let me know.
Scott

aravindhan_3
10-02-2008, 08:07 PM
Hi,
Thanks for your help, however i dont know VBA in outlook, I understood your logic, but not sure how to put this in a code..

I would appreciate your help...if you could provide me the code.

thanks again for helping me...

Demosthine
10-02-2008, 10:03 PM
Hey there.

I don't usually just provide code for people. It tends to be more of a learning experience when you help someone through it rather than doing it for them. This one is so short and simple, though, the code is below.

The Redirected folder should be a folder inside of your default Inbox. Also, it will only forward messages that are marked Unread and will mark the Read right before it forwards it. This will help prevent it from sending the same message several times if you have not moved/deleted the message after you forward it.


Option Explicit

Public Sub Forward_All()
' Declare variables to access your Inbox Folder and your
' Redirected Sub-Folder.
Dim folInbox As MAPIFolder
Dim folRedirected As MAPIFolder
' Declare variables to access each of the messages in your
' Sub-Folder and then the new message that is being
' Forwarded.
Dim olmMessage As MailItem
Dim olmForward As MailItem

' Set your Inbox Object to reference your Default Inbox.
Set folInbox = Session.GetDefaultFolder(olFolderInbox)
' Set your Redirected Object to reference the Sub-Folder
' within your Default Inbox.
Set folRedirected = folInbox.Folders.Item("Redirected")

' Loop through all messages in the Redirected Folder.
For Each olmMessage In folRedirected.Items
' If the message has not been marked Read, then we
' will Forward the message.
If olmMessage.UnRead = True Then
' Mark the message as Read.
olmMessage.UnRead = False
' Set the Forward Object to the new message created
' by the Forward Method.
Set olmForward = olmMessage.Forward
' Set the various properties of the new email.
With olmForward
' Set the Address we are forwarding the message to.
.To = "name@domain.com"
' Send the message immediately.
.Send
End With
End If
Next olmMessage
End Sub


Hope this answers it all for you.
Scott

aravindhan_3
10-03-2008, 07:57 AM
Hi,

Thatz perfect.. Thanks a lot....for helping me...