MailAsAttachment
MailMergeSettings.MailAsAttachment property
指定在邮件合并操作期间生成的文档应作为附件而不是 而不是实际电子邮件的正文通过电子邮件发送。默认值为错误的
.
public bool MailAsAttachment { get; set; }
例子
演示如何在连接到外部数据源时执行邮件合并。
Document doc = new Document(MyDir + "Odso data.docx");
MailMergeSettings settings = doc.MailMergeSettings;
Console.WriteLine($"Connection string:\n\t{settings.ConnectString}");
Console.WriteLine($"Mail merge docs as attachment:\n\t{settings.MailAsAttachment}");
Console.WriteLine($"Mail merge doc e-mail subject:\n\t{settings.MailSubject}");
Console.WriteLine($"Column that contains e-mail addresses:\n\t{settings.AddressFieldName}");
Console.WriteLine($"Active record:\n\t{settings.ActiveRecord}");
Odso odso = settings.Odso;
Console.WriteLine($"File will connect to data source located in:\n\t\"{odso.DataSource}\"");
Console.WriteLine($"Source type:\n\t{odso.DataSourceType}");
Console.WriteLine($"UDL connection string:\n\t{odso.UdlConnectString}");
Console.WriteLine($"Table:\n\t{odso.TableName}");
Console.WriteLine($"Query:\n\t{doc.MailMergeSettings.Query}");
// 我们可以通过清除它们来重置这些设置。一旦我们这样做并保存文档,
// 当我们使用 Microsoft Word 加载文档时,它将不再执行邮件合并。
settings.Clear();
doc.Save(ArtifactsDir + "MailMerge.OdsoEmail.docx");
也可以看看
- class MailMergeSettings
- 命名空间 Aspose.Words.Settings
- 部件 Aspose.Words