【问题标题】:Attachments becoming embedded附件嵌入
【发布时间】:2015-11-12 02:39:31
【问题描述】:

我有一个 Excel 宏,用于发送带有 Excel 工作簿附件的电子邮件。有时,它不是附加的文件,而是一个嵌入的对象。该嵌入对象可由公司内的用户打开(在单击“您将要激活可能包含病毒或对您的计算机有害的嵌入对象后。重要的是要确定它来自可信赖的来源。你想继续吗?”),但对于公司以外的人来说,电子邮件似乎根本没有附件。

这似乎是随机发生的,并且仅在某些计算机上发生。因此,如果该列表有 15 个电子邮件列表和附件,那么它恰好出现在 0 到 15 封电子邮件之间。明确地说,我的目标是发送带有常规附件的电子邮件。运行 Excel 2003、Outlook 2003 和 Windows XP。

Sub Email()  
Dim P As String  
Dim N As String  
Dim M As String  
Dim Subject As String  
Dim Addresses As String  
Dim olApp As Outlook.Application  
Dim olNewMail As Outlook.MailItem  

Application.DisplayAlerts = False  

M = ActiveWorkbook.Name  

For c = 2 To 64000  
    If Range("B" & c) = "" Then Exit For  
    If UCase(Range("E" & c)) = "Y" Then  
        Workbooks(M).Sheets("Main").Activate  
        Subject = Range("A" & c)  
        Addresses = Range("B" & c)  
        P = Range("C" & c)  
        N = Range("D" & c)  
        If Right(P, 1) <> "\" Then P = P & "\"  
        If Right(N, 4) <> ".xls" Then N = N & ".xls"  
        Set olApp = New Outlook.Application  
        Set olNewMail = olApp.CreateItem(olMailItem)  
        With olNewMail  
            .Display  
            .Recipients.Add Addresses  
            Application.Wait (Now + TimeValue("0:00:01"))  
            SendKeys ("{TAB}")  
            .Subject = Subject  
            .Attachments.Add P + N  
            .Send  
        End With  
        Set olNewMail = Nothing  
        Set olApp = Nothing  

    End If  
Next c  

Range("E2:E65536").ClearContents  
Application.DisplayAlerts = True  

End Sub  

【问题讨论】:

    标签: email vba outlook attachment


    【解决方案1】:

    您可能只需要使用 olMailItem.BodyFormat 属性显式设置消息格式:http://msdn.microsoft.com/en-us/library/aa211430(v=office.11).aspx

    听起来它显示为富格式消息(附件作为嵌入对象)而不是 HTML 格式的电子邮件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 2020-12-04
      • 2014-07-05
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 2020-08-08
      相关资源
      最近更新 更多