G
Guest
I'm running MS Outlook 2003 with SP2 on Win XP home.
With a given e-mail message selected, I would like, with one click of a
custom toolbar button, to do the following:-
1. Add sender to blocked e-mail list
2. Move the e-mail to the Junk e-mail folder
I realise there are menu items for these, but I need to automate.
Unfortunately, as Outlook appears to have no Record Macro capability, I am
having difficulty writing appropriate code.
I've done the custom button and got this far with item 2:-
Sub MyJunk()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim myDestFolder As Outlook.MAPIFolder
Set myDestFolder = Application.Explorers.Item("Junk E-mail")
myOlSel.Move myDestFolder
End Sub
It steps thru ok until the last line of code when, I get the following error:-
"Object variable or With block variable not set"
I don't know how to write code for Item for 1.
Any suggestions would be appreciated.
With a given e-mail message selected, I would like, with one click of a
custom toolbar button, to do the following:-
1. Add sender to blocked e-mail list
2. Move the e-mail to the Junk e-mail folder
I realise there are menu items for these, but I need to automate.
Unfortunately, as Outlook appears to have no Record Macro capability, I am
having difficulty writing appropriate code.
I've done the custom button and got this far with item 2:-
Sub MyJunk()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim myDestFolder As Outlook.MAPIFolder
Set myDestFolder = Application.Explorers.Item("Junk E-mail")
myOlSel.Move myDestFolder
End Sub
It steps thru ok until the last line of code when, I get the following error:-
"Object variable or With block variable not set"
I don't know how to write code for Item for 1.
Any suggestions would be appreciated.