[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Outlook VBA Programming - Forward Selected Email To Set Address

Posted on 2006-04-18
4
Medium Priority
?
498 Views
Last Modified: 2010-04-17
Hi,

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"
myForward.Send"

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?

thanks

david jacques

0
Comment
Question by:cmrecruitment
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:alifaik
ID: 16500816
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
0
 

Author Comment

by:cmrecruitment
ID: 16505875
Hi,

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"


thanks
david jacques
0
 
LVL 1

Accepted Solution

by:
alifaik earned 2000 total points
ID: 16511581
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"
        myforward.Send
    Next x
 


End Sub
0
 

Author Comment

by:cmrecruitment
ID: 16523360
Thanks for the help.

This is really going to help us out.

Enjoy the points.

thanks david jacques
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question