日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MSFT Outlook VBA处理新邮件的方法

發布時間:2023/12/9 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MSFT Outlook VBA处理新邮件的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

俺們有兩個郵箱,1個外部的郵箱1(outlook),1個內部郵箱0(lotus notes)。想要outlook郵箱收到新郵件之后判斷一下subject的內容,如果是"kkk:"開頭,則將"kkk:"后面的內容作為to發到lotus notes的郵箱里面去。

測試環境(xp+msft outlook),按alt+F11進入VBA編輯。注意要在工具 -> 宏 -> 安全性中設置為低。部分代碼如下(手抄的,可能有錯哦~~):

option explicit

public WithEvents outApp as Outlook.Application

?

Sub Initialite_handle ()

  set outApp = Application

End Sub

?

' 打開OutLook的時候調用,注冊application引用

private sub Application_Startup ()

  Initialize_handle

End Sub

'注意函數命名,收到新郵件的時候自動調用

Private sub outApp_NewMailEx (ByVal EntryIDCollection As String)

  Dim mai As Object

  Dim intInitial As Integer

  Dim intFinal As Integer

  Dim strEntry As String

  Dim intLength As Integer

?

  intInitial - 1

  intLength = Len(EntryIDCollection)

  intFinal = InStr(intInitial, EntryIDCollection, ",")

  Do While intFinal <> 0

    strEntryID = Stringmid(EntryIDCollection, intInitial, (intFinal - intInitial))

    set mai = Application.Session.GetItemFromID(strEntryID)

    newmail_proc mai

    intInitial = intFinal +1

    intFinal = inStr(intInitial, EntryIDCollection, ",")

  Loop

  strEntryID = String.mid(EntryIDCollection, intInitial, (intLength - intInitial)+1)

  set mai = Application.Session.GetItemFromID(strEntryID)

  newmail_proc mai

End Sub

?

private sub newmail_proc (ByVal mai As Object)

  Dim itm As Object

  Dim result As Integer

  Dim str_kkk As String

  Dim str_subject As String

  Dim len_subject As Integer

  Dim str_body As String

  Dim str_reception As String

?

  str_subject = mai.subject

  len_subject = Len(str_subject)

?

  str_kkk = String.mai(str_subject, 1, 4)

  result = String.strComp(str_kkk, "kkk:", vbTextComare)

  if result <> 0 then

  Else

    String_reception = String.mid(str_subject, 5, (len_subject-4)+1)

    str_body = mai.body

    set Itm = outApp.CreateItem(0)

    with Itm

      .subject = "new mail from a@a.com"

      .to = str_reception

      .body = str_body

      .send

    End With

  End if

End Sub

總結

以上是生活随笔為你收集整理的MSFT Outlook VBA处理新邮件的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。