自动生成邮件不是解决多个收件人 [英] Automated email generation not resolving multiple recipients

查看:428
本文介绍了自动生成邮件不是解决多个收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有它创建与放一个VBA脚本;保存电子邮件草稿。要添加收件人,它拉从一个链接的Excel表中的字符串,并将其添加到收件人对象。

有关邮件的单收件人,这个工程就像一个魅力。所有用户需要做的就是打开草案,花5秒找了一下,然后点击发送。

的问题与多个联系人发生一次(如a@aol.com; b@aol.com; c@aol.com)。当用户点击发送,Outlook将弹出,没有一个建议检查名称对话。用户可以通过点击收件人字段,并进入一个虚拟的分号来触发自动决心解决这个问题。我想避免这种情况,因为这个过程在上一次一百电子邮件这需要单独审查创造良好。

环顾上了网,我发现并试图Recipients.ResolveAll返回假的。我怀疑的原因是,Outlook正在试图解决收件人的整个字符串一次,而不是个别。所以我的问题是:如何获得Outlook停止显示该检查姓名的对话?我是否需要环通我的电子邮件串并分析出单个电子邮件?

 子CreateEmail(ID为整数)
    昏暗OlApp作为Outlook.Application
    昏暗ObjMail作为Outlook.MailItem
    昏暗的收件人作为Outlook.Recipients
    昏暗CurrentRecipient作为Outlook.Recipient

    设置OlApp =的CreateObject(Outlook.Application)
    设置ObjMail = OlApp.CreateItem(olMailItem)
    设置收件人= ObjMail.Recipients

    昏暗StrEmailTo作为字符串
    StrEmailTo = CurrentDb.OpenRecordset(_
        &AMP从LU_Contacts其中id =选择[电子邮件]; ID和放大器; ;。)的字段(0)

    设置CurrentRecipient = Recipients.Add(STRCONV(StrEmailTo,3))
    CurrentRecipient.Type = olTo
    ...

    Objmail.Save
 

解决方案

Recipients.Add 接受一个电子邮件地址。

如果你想有多个收件人,叫 Recipients.Add 的每一个。

如果您的字符串在返回; 分隔的格式,然后是这样的:

 昏暗的emailList为Variant
昏暗的NumEmails只要
昏暗AddEmailLoop只要

的emailList =分割(StrEmailTo,;)
NumEmails = UBound函数(的emailList)

对于AddEmailLoop = 0至NumEmails
    Recipients.add(的emailList(AddEmailLoop))
下一个
 

应该允许您添加整个列表

I have a VBA script which creates & saves Draft emails. To add recipients, it pulls a string from a linked Excel table and adds that to the Recipients object.

For emails with single recipients, this works like a charm. All the user needs to do is open the draft, spend 5 seconds looking it over, and hit Send.

The problem occurs with several contacts at once (e.g. "a@aol.com; b@aol.com; c@aol.com"). When the user hits Send, Outlook will pop up a Check Names dialogue with no suggestions. The user can get around this by clicking on the To field and entering a dummy semicolon to trigger the auto resolve. I'd like to avoid this since this process creates well over a hundred emails at a time which need to be individually reviewed.

Looking around on the net, I've found and tried Recipients.ResolveAll which returns false. I suspect the reason is that Outlook is trying to resolve the entire string of recipients at once and not individually. So my question is: how do I get Outlook to stop displaying this Check Names dialogue? Do I need to loop thru my email string and parse out the individual emails?

Sub CreateEmail(id as Integer)
    Dim OlApp As Outlook.Application
    Dim ObjMail As Outlook.MailItem
    Dim Recipients As Outlook.Recipients
    Dim CurrentRecipient As Outlook.Recipient

    Set OlApp = CreateObject("Outlook.Application")
    Set ObjMail = OlApp.CreateItem(olMailItem)
    Set Recipients = ObjMail.Recipients

    Dim StrEmailTo As String
    StrEmailTo = CurrentDb.OpenRecordset( _
        "Select [Emails] from LU_Contacts where id=" & id & ";").Fields(0)

    Set CurrentRecipient = Recipients.Add(StrConv(StrEmailTo, 3))
    CurrentRecipient.Type = olTo
    ...

    Objmail.Save

解决方案

Recipients.Add takes a single email address.

If you wish to have multiple recipients, call Recipients.Add for each one.

If your string is returned in a ; delimited format, then something like:

dim EmailList as variant
dim NumEmails as long
dim AddEmailLoop as long

EmailList=split(StrEmailTo,";")
NumEmails=UBound(EmailList)

For AddEmailLoop=0 to NumEmails
    Recipients.add(EmailList(AddEmailLoop))
next

should allow you to add the entire list

这篇关于自动生成邮件不是解决多个收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆