none
save email from excel RRS feed

  • General discussion

  • Dear Sir
    wishing you a good day.

    we have a Excel VBA code that saves the selected email from outlook and hyperlinks a cell to it. but the problem is when the selected email is from a search result on "All Mailboxes". I would be thankful if you check what the problem is and let me know.

    Sub LinkToQuotation()
    Dim oMail As Outlook.MailItem
    Dim objItem As Object
    Dim sPath As String
    Dim dtDate As Date
    Dim sName As String
    Dim enviro As String
    enviro = CStr(Environ("USERPROFILE"))
    For Each objItem In ActiveExplorer.Selection
    Set oMail = objItem
    sName = oMail.Subject & ".msg"
    ReplaceCharsForFileName sName, " "
    sPath = "D:\Dropbox\calc quotations\"
    Debug.Print sPath & sName
    oMail.SaveAs sPath & sName, olMSG
    Range("E3").Select
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=sPath & sName, TextToDisplay:="Link to Email"
    Next
    End Sub
    Best Regards
    Shahrooz Bral

    Monday, July 22, 2019 7:48 PM