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

如何在VisualWorks Smalltalk中通过Outlook添加附件发送邮件?

Outlook邮件添加附件的正确方法

你之前直接用setProperty: #Attachments value: 'C:\temp\file.txt'不行,是因为Outlook的Attachments是集合对象,不是普通字符串属性,不能直接赋值,必须调用集合的Add方法来添加附件。

修改后的完整代码如下:

(t2 :=  (COMDispatchDriver createObject: 'Outlook.Application') invokeMethod: #CreateItem withArguments: #(0)) 
    setProperty: #To value: 'x.x@abc.com';
    setProperty: #CC value: '';
    setProperty: #Subject value: 'Test';
    setProperty: #Body value: 'Here comes the file';
    "添加附件:先获取Attachments集合,再调用Add方法传入文件路径"
    getProperty: #Attachments;
        invokeMethod: #Add withArguments: #('C:\temp\file.txt');
    invokeMethod: #Send withArguments: #().

session release.

关键说明:

  • 先通过getProperty: #Attachments获取邮件的附件集合对象
  • 调用该集合的Add方法,把文件路径作为参数传入(参数要放在数组里,符合invokeMethod:withArguments:的要求)
  • 这样就能正确将指定文件添加为邮件附件,之后再调用Send发送即可

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 10:12:02