2015-08-28 64 views
0

我想讓我的vba代碼自動在Outlook中顯示一個電子郵件。我無法將附件顯示爲郵件正文中的圖標(圖1)。我毫不費力地將它顯示在主題行下(圖2)。如何使用vba在outlook中定位電子郵件正文中的附件?

With OutMail 
    .To = MailList 
    .CC = "" 
    .BCC = "" 
    .Subject = "Teddy Bear Test" 
    .HTMLBody = "<p style='font-family:Arial;font-size:13'> Hello Team: <br><br> Thank You<br><br>" 
    .Attachments.Add teddybear.xlsx, , 999 
    .Display 
End With 

我需要做什麼來修復我的代碼?

enter image description here

enter image description here

+0

本文可能對使用Outlook有所幫助。 https://support.office.com/zh-CN/my/article/Why-do-some-attachments-appear-in-the-message-body-12829ec7-6cd8-4992-9621-3d1572810335 – Lumigraphics

回答

0

改變這樣的格式。

Option Explicit 

Sub AttachmentInBody() 

Dim OutMail As MailItem 

Set OutMail = Application.CreateItem(0) 

With OutMail 

    .To = "MailList" 
    .CC = "" 
    .BCC = "" 
    .Subject = "Teddy Bear Test" 

    .Display 

    If .BodyFormat <> olFormatRichText Then .BodyFormat = olFormatRichText 

    .body = "Hello Team:" & vbCr & vbCr & "Thank You" & vbCr 

    .Attachments.Add teddybear.xlsx, , 999 

End With 

Set OutMail = Nothing 

End Sub 
相關問題