Outlook 2007 comes with the email recall function. Version 2003 does not exist. Unfortunately, this version is the most pirated version and has a wide range of users. In this project, the number of users in outlook2003 is large, reaching 397.
It is impossible for them to install 2007/2010 or so on, so they should use the VBA macro editor in the outlook2003 "tool" menu for development.
Prerequisites for email recall:
1. It must be an exchange email.
2. The recipient must be an Outlook client, which is not supported by OWA.
3. The recipient must have not read the email.
Private withevents vsocommbandbutton as commandbarbutton
Private withevents vsocommbandrecallmessage as commandbarbutton
Dim item as object
Private sub application_startup ()
Call addtotalbutton
End sub
'Add Toolbar
Sub addtotalbutton ()
On Error resume next
Dim vsocommandbar as commandbar
'Get the toolbar to be added
Set vsocommandbar = outlook. activeexplorer. commandbars ("excelclub ")
'If the toolbar is empty, add
If (vsocommandbar is nothing) then
Set vsocommandbar = outlook. activeexplorer. commandbars. Add ("excelclub", msobartop)
'Add a button on the toolbar.
Set vsocommbandrecallmessage = vsocommandbar. Controls. Add (1)
Vsocommbandrecallmessage. Caption = "recallmail"
Vsocommbandrecallmessage. faceid = 72
Vsocommbandrecallmessage. Style = msobuttoniconandcaption
'Display the added Toolbar
Vsocommandbar. Visible = true
Else
Set vsocommbandrecallmessage = vsocommandbar. Controls (1)
End if
End sub
'Execute the added button (recallmail)
Private sub vsocommbandrecallmessage_click (byval CTRL as office. commandbarbutton, canceldefault as Boolean)
'The code continues to run when an error occurs
On Error resume next
Dim objns as outlook. namespace
Dim myitem as outlook. mailitem, objsendfolder as outlook. mapifolder
Dim objitems as outlook. Items
Dim tmpitem as object
Set objns = application. getnamespace ("mapi ")
Set objsendfolder = objns. getdefaultfolder (olfoldersentmail)
Set objitems = objsendfolder. Items
Objitems. Sort "[senton]", true
Set tmpitem = objitems. getfirst
Do While typename (tmpitem) <> "nothing"
If typename (tmpitem) = "mailitem" then
Set myitem = tmpitem
Exit do
End if
Set tmpitem = objitems. getnext
Loop
Set item = myitem
Item. Display
Call showattachmentdialog
Myitem. Close oldiscard
End sub
Sub showattachmentdialog ()
Dim objinsp
Dim colcb
Dim objcbb
On Error resume next
Set objinsp = item. getinspector
Set colcb = objinsp. commandbars
Sets objcbb = colcb. findcontrol (, 2511)
If not objcbb is nothing then
Sendkeys "{enter}", wait
Objcbb. Execute
End if
Set objcbb = nothing
Set colcb = nothing
Set objinsp = nothing
End sub