VBA Outllook forwarding e-mail

Hi,

In VBA I am trying to forward an e-mail to a certain e-mail address. The code (snap shot) is below. The error message is "Outlook does not recognise one or more names". I have double checked the e-mail address is correct so do not understand what is going on.

Any help would be great!

Dim Email As Outlook.MailItem

    Email.Forward
    Email.Recipients.Add "Christopher.Mey@fandc.com"
    Email.Send

Open in new window

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

jsdrayCommented:
try line 4 like this:

Email.Recipients.Add ("Christopher.Mey@fandc.com")
0
Chris BottomleySoftware Quality Lead EngineerCommented:
You cannot use the new syntax with creating outlook items in that way:

See below which will be fine .. as it stands email in your code was nothing due to the invalid syntax and 'nothing' cannot have recipients.

Chris
Dim Email As Outlook.MailItem

    Set Email = Application.CreateItem(olMailItem)
    With Email
        Email.Recipients.Add "Christopher.Mey@fandc.com"
        Email.Send
    End With

Open in new window

0
Chris BottomleySoftware Quality Lead EngineerCommented:
Within the specifics of a forward ... you need an email to process but as long as you do then the following will process a forward to the active email.

inspector is an open email whereas explorer as currently shown is the selected item in the outlook folder explorer

Chris
Dim mai As MailItem

'    Set mai = Application.ActiveInspector.CurrentItem
    Set mai = Application.ActiveExplorer.Selection(1)
    
    With mai.Forward
        .Recipients.Add "Christopher.Mey@fandc.com"
        .Display
    End With

Open in new window

0

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
Chris BottomleySoftware Quality Lead EngineerCommented:
Note I set display rather than send to prevent accidently sending an email ... just change it back.

Chris
0
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
Outlook

From novice to tech pro — start learning today.