Append Inhalt .msg-Anlage zum Nachrichtentext

Ich habe ein Skript zum öffnen von Anhängen und fügen Sie diese in den Nachrichtentext. Ich habe es die Arbeit für text-Dokumente, aber ich brauche es für die Arbeit .msg-Anhänge zu.

Im moment ist es einfach nicht das Objekt Lesen. Kann mir jemand helfen?

Sub RunAScriptRuleRoutine(MyMail As MailItem)

Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim olMailAT As Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)

If olMail.Subject = "lala" Then

    If olMail.Attachments.Count > 0 Then

        Dim strLine As String
        Dim mailLine As String
        Dim strLines As String

        For i = 1 To olMail.Attachments.Count

            strFileName = "C:\emailTemp\" + olMail.Attachments.Item(i).FileName

            If InStr(strFileName, "msg") Then

                olMail.Attachments.Item(i).SaveAsFile strFileName
                strLines = strLines + "//Start of " + strFileName + " //" + vbCrLf

                Open strFileName For Input As #1
                    Do While Not EOF(1)
                    Line Input #1, strLine
                        mailLine = mailLine + strLine
                    Loop
                Close #1

                olMailAT = mailLine
                strLine = objMailAT.Body
                strLines = strLines + "heres the .msg" + vbCrLf
                strLines = strLines + "//End of " + strFileName + " //" + vbCrLf

            Else

                olMail.Attachments.Item(i).SaveAsFile strFileName

                strLines = strLines + "//Start of " + strFileName + " //" + vbCrLf
                Open strFileName For Input As #1
                    Do While Not EOF(1)
                    Line Input #1, strLine
                        strLines = strLines + vbCrLf + strLine
                    Loop
                Close #1
                strLines = strLines + "//End of " + strFileName + " //" + vbCrLf

            End If

        Next

        'save to email body and save email
        olMail.Body = strLines
        olMail.Save

    End If

End If

Set olMail = Nothing
Set olNS = Nothing

End Sub
InformationsquelleAutor Josh | 2010-06-22
Schreibe einen Kommentar