Outlook VBA Programming - Forward Selected Email To Set Address


I am trying to create a VBA macro to forward a selected email to a set email address e.g. "no_email@candm.co.uk".

I have already got this script -
"Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myfolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myForward = myfolder.Items(4).Forward
myForward.Recipients.Add "no_email@candm.co.uk"

The problem with the code above is that you have to pre-define the email item before you run the macro. I want to be able to select the email item instead of pre-defining it.

We are currently using Outlook 2000.

Any ideas?


david jacques

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi , what do you mean exactly by email item?
why dont you add an InputBox() to be asked for the emai iteml each time you use the function
cmrecruitmentAuthor Commented:

I mean the email currently selected within outlook.

Basically I would like to select an email within my outlook and then click a macro which forwards the email off to a set email address e.g. "no_email@candm.co.uk"

david jacques
Hi , I have written this sub and it works,  you just select the email that you would like to send, regardless whether in the inbox or elsewehre, enjoy !

Sub explorerNames()
Dim myOlApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim MsgTxt As String
    Dim x As Integer
    Dim myNms As Outlook.NameSpace
    Dim myFolder As Outlook.MAPIFolder
    Dim myRecipient As Outlook.Recipient
    Dim myItem As MailItem
    MsgTxt = "You have selected items from: "
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
    Set myItem = myOlSel.Item(1)
    For x = 1 To myOlSel.Count
              MsgTxt = myItem.SenderName
        Set myforward = myItem.Forward
        myforward.To = "dummyName@dummyServer.com"
    Next x

End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cmrecruitmentAuthor Commented:
Thanks for the help.

This is really going to help us out.

Enjoy the points.

thanks david jacques
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.