You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过未绑定文本框为Outlook.MailItem添加附件时触发Error 438

邮件附件路径从文本框取值时触发Error 438问题

我能发送带附件的邮件,但只有附件路径硬编码时才正常运行,代码如下:

With olMail
    .To = Me.EmailTo
    .CC = Me.EmailCC
    .Subject = Me.EmailSubject
    .BodyFormat = olFormatPlain
    .Body = Me.EmailMessage
    .Attachments.Add "C:\Users\pat.lewis\Desktop\description.docx"
    .Send
End With

我的表单上有个名为LinkedFile1的未绑定文本框,赋值代码是:

Me.LinkedFile1 = "C:\\Users\\pat.lewis\\Desktop\\description.docx"

但当我把Me.LinkedFile1的值传给.Attachments.Add时,代码无法运行:

With olMail
    .To = Me.EmailTo
    .CC = Me.EmailCC
    .Subject = Me.EmailSubject
    .BodyFormat = olFormatPlain
    .Body = Me.EmailMessage
    .Attachments.Add Me.LinkedFile1 '无法运行!!
    .Send
End With

该行代码会触发如下错误:

error 438: Object doesn't support this property or method

.Attachments.Add Me.LinkedFile1

就算把Me.LinkedFile1的值赋给字符串变量再引用,还是不行:

Dim olAttachment1 As String

If IsNull(Me.AttachedFile1) = False Then
    olAttachment1 = Me.LinkedFile1
End If

With olMail
    .To = Me.EmailTo
    .CC = Me.EmailCC
    .Subject = Me.EmailSubject
    .BodyFormat = olFormatPlain
    .Body = Me.EmailMessage
    .Attachments.Add olAttachment1 '还是无法运行!!
    .Send
End With

内容的提问来源于stack exchange,提问作者Pattrick Lewis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 06:55:13