vba
  • email
  • hyperlink
  • outlook
  • move
  • 2016-02-05 123 views 0 likes 
    0

    我想將郵件移動到不同的文件夾,然後將鏈接返回到移動的郵件。如果沒有移動它的工作原理爲:Outlook VBA鏈接到移動的郵件

    Dim objMail As Outlook.MailItem 
    Dim sFrag As String 
    Set objMail = Application.ActiveExplorer.Selection.Item(i_item) 
    sFrag = "<a href='outlook:" + objMail.EntryID + "'>" + objMail.Subject + "</a>"" 
    

    在這裏有串sFrag在適當的超級鏈接提供了一個有效的Outlook元素。如果我點擊一個包含此屬性的超鏈接,該元素將在Outlook中打開。

    但是,如果我這樣擴大到:

    Dim objMail As Outlook.MailItem 
    Dim sFrag As String 
    Dim oOlApp As Outlook.Application 
    Dim targetFolder As folder 
    
    Set objMail = Application.ActiveExplorer.Selection.Item(i_item) 
    Set oOlApp = Outlook.Application 
    Set objNmSpc = oOlApp.GetNamespace("MAPI") 
    Set targetFolder = objNmSpc.PickFolder 
    objMail.Move targetFolder 
    sFrag = "<a href='outlook:" + objMail.EntryID + "'>" + objMail.Subject + "</a>" 
    

    後,在sfrag鏈接失敗。如果我想打開此鏈接,Outlook-Windows將顯示Operation failed。似乎objMail.EntryIDobjMail.Move命令後未正確更新。

    爲什麼?如何解決這個問題?

    回答

    1

    移動是一個函數,而不是一個子 - 它retruns新項目:

    set objMail = objMail.Move(targetFolder) 
    
    +0

    沒有工作。感謝你的快速幫助。 – BerndGit

    相關問題