為outlook增加「郵件召回」功能

2021-06-16 21:11:28 字數 2540 閱讀 8984

outlook 2007開始軟體自帶郵件召回功能。2003版本沒有,可惜此版本盜版最厲害,使用者很廣,這次專案中使用者分布很廣,其中outlook2003版本使用者數甚多,達到397人。

不可能讓他們新裝2007/2010等,因此使用outlook2003「工具」選單中的vba巨集編輯器進行開發

郵件召回的前提:

1、必須是exchange郵件

2、收件人必須是outlook客戶端,owa不支援

3、收件人必須未讀郵件

private withevents vsocommbandbutton as commandbarbutton

private withevents vsocommbandrecallmessage as commandbarbutton

dim item as object

call addtotalbutton

end sub

'增加工具欄

sub addtotalbutton()

on error resume next

dim vsocommandbar as commandbar

'得到要新增的工具欄

set vsocommandbar = outlook.activeexplorer.commandbars("excelclub")

'如果工具欄為空,則增加

if (vsocommandbar is nothing) then

set vsocommandbar = outlook.activeexplorer.commandbars.add("excelclub", msobartop)

'在工具欄上增加乙個按鈕

set vsocommbandrecallmessage = vsocommandbar.controls.add(1)

vsocommbandrecallmessage.caption = "recallmail"

vsocommbandrecallmessage.faceid = 72

vsocommbandrecallmessage.style = msobuttoniconandcaption

'顯示增加的工具欄

vsocommandbar.visible = true

else

set vsocommbandrecallmessage = vsocommandbar.controls(1)

end if

end sub

'增加的按鈕(recallmail)的執行

private sub vsocommbandrecallmessage_click(byval ctrl as office.commandbarbutton, canceldefault as boolean)

'出現錯誤時下一句**繼續執行

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 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

set objcbb = colcb.findcontrol(, 2511)

if not objcbb is nothing then

sendkeys "", wait

objcbb.execute

end if

set objcbb = nothing

set colcb = nothing

set objinsp = nothing

end sub

將Foxmail郵件匯入Outlook

前兩天boss要換郵件客戶端軟體,由原來的foxmail改為outlook 不是oe 本來嘛換個軟體沒什麼事的,結果在匯入原有郵件時出了點小麻煩了 花了少許時間最終搞定,記一下供參考。foxmail衹提供從oe等郵件客戶端軟體匯入,而匯出則衹能是單個的.msg或.eml檔案,outlook不能直接從...

C 呼叫outlook 傳送郵件

1.這個是呼叫ie mailto 來傳送的,呼叫win api 首先要新增引用using system.runtime.interopservices class mailto 與我聯絡開啟郵箱的類 2 呼叫 ie方法 system.diagnostics.process.start mailto ...

Python 呼叫 Outlook 傳送郵件

import win32com.client as win32 defsend mail outlook win32.dispatch mail item outlook.createitem 0 0 olmailitem mail item.recipients.add someone qq.co...