首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自数组或列表的MailMerge

来自数组或列表的MailMerge
EN

Stack Overflow用户
提问于 2012-08-16 12:06:55
回答 1查看 3.4K关注 0票数 0

this site中,有一个关于使用2个数组和MailMerge.Execute方法进行邮件合并的示例,但该方法不接受2个参数。

不管怎样,有没有办法用2个数组或2个列表来做类似的事情呢?

谢谢。

这是他们使用的代码:

代码语言:javascript
复制
    // Open an existing document.
    Document doc = new Document(MyDir + "MailMerge.ExecuteArray.doc");

    // Fill the fields in the document with user data.
    doc.MailMerge.Execute(
    new string[] {"FullName", "Company", "Address", "Address2", "City"},
    new object[] {"James Bond", "MI5 Headquarters", "Milbank", "", "London"});

这是我想要实现的方法:

代码语言:javascript
复制
    private void ReplaceMailMergeField(String plantilla, String[] campos, Object[] valores)
    {
        Object oMissing = System.Reflection.Missing.Value;
        Object oTrue = true;
        Object oFalse = false;
        Word.Application wordApp = new Word.Application();
        Word.Document wordDoc = new Word.Document();
        wordApp.Visible = true;
        Object templatePath = plantilla;
        wordDoc = wordApp.Documents.Add(ref templatePath, ref oMissing, ref oMissing, ref oMissing);
        wordDoc.MailMerge.Execute(campos, valores);
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-16 12:28:49

第一段接受两个数组的代码是用于.NET的Aspose Word,这是一个独立于MS Word的组件。

MS Word MailMerge.Execute()是一种不同的方法,它只接受一个可选参数。

要在安装了C#和office的情况下自动执行邮件合并,请参阅以下文章:

KB301659 How to automate Microsoft Word to perform Mail Merge from Visual C#

http://everythingsharepoint.blogspot.in/2011/12/c-microsoft-word-2010-automated-mail.html

http://everythingsharepoint.blogspot.in/2011/12/c-microsoft-word-2010-automated-mail_01.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11980564

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档