Consulting

Results 1 to 2 of 2

Thread: Save selected messages VBA does not save replied messages

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Save selected messages VBA does not save replied messages

    Hi all,

    So please see the VBA code i'm using to save selected messages to a folder of my choice. I noticed that whenever i try to save responded mails, it fails to save as an .eml file and just turns into a blank file (attached image). Please see code below, what am I doing wrong? This is really giving me stress.

    Public Sub SaveMessageAsMsg()
    'Update by Extendoffice 2018/3/5
    Dim xMail As Outlook.MailItem
    Dim xObjItem As Object
    Dim xPath As String
    Dim xDtDate As Date
    Dim xName, xFileName As String
    On Error Resume Next
    Set xShell = CreateObject("Shell.Application")
    Set xFolder = xShell.BrowseForFolder(0, "Select a folder:", 0, strStartingFolder)
    If Not TypeName(xFolder) = "Nothing" Then
    Set xFolderItem = xFolder.self
    xFileName = xFolderItem.Path & ""
    Else
    xFileName = ""
    Exit Sub
    End If
    For Each xObjItem In Outlook.ActiveExplorer.Selection
    If xObjItem.Class = olMail Then
    Set xMail = xObjItem
    xName = xMail.Subject
    xDtDate = xMail.ReceivedTime
    xName = Format(xDtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(xDtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & xName & ".msg"
    xPath = xFileName + xName
    xMail.SaveAs xPath, olMSG
    End If
    Next
    End Sub
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •