本文介绍了GmailApp.sendEmail()来自Plus地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:是否有办法覆盖帐户电子邮件地址并将其替换为同一帐户上的加号地址?

我正在使用GmailApp.sendEmail ()方法。



帐户电子邮件地址是非加号(明显)地址,但我使用多个加号地址将邮件过滤为类别。



当我使用sendEmail()发送邮件时,它使用主帐户地址,并且似乎没有办法对脚本进行更改。 p>

虽然我可以为帐户设置名称,但我想将发件人地址设置为帐户地址的加号版本。



(我记得使用Calendar用户界面遇到了同样的问题)。

所以,我也尝试使用高级设置来设置replyTo地址参数。 (这不是我喜欢这样做的方式。)



replyTo参数显然接受地址,并且发送的消息包含回复头。

 交付给:例子+ test @ gmail我已经在下面用'example'代替了账户地址。 .com 

回复:Richard Michael< example+pch@gmail.com>

来自:Richard Michael< example@gmail.com>
至:example+test@gmail.com

当我在Gmail中使用回复按钮时但是,在表单中加载的'To'地址是example+test@gmail.com,这是我所期望的两种可能性之一。 (它应该是回复,或者最坏的情况下是发件人地址。)回复表单中的发件人地址是example@gmail.com,这是预期的(但也是我想从加号地址'发送'的原因)。

我重复了几次,结果相同。



当然,Gmail也允许您在执行验证检查后,还可以在用户界面中从外部帐户发送。因此,您无法从这些地址发送。

解决方案

您必须使用方法中的参数: GmailApp.sendEmail 。



示例

  GmailApp.sendEmail('example@exapmle.com','Testmail','Hello Richard',
{姓名:'Richard Michel',来自:'example+pch@gmail.com',});

我使用,我编辑了一些代码



函数fnMailmerge()我添加了行

  top_panel.add(myapp.createLabel(请选择您的别名)); 
var lf = myapp.createListBox(false).setWidth(250).setName('from')。addItem(Select aliases ...)。setVisibleItemCount(1); (var i = 0; i< aliases.length; i ++){
lf.addItem(aliases [i]);


}

top_panel.add(lf);

,添加了最后一条语句(在同一个函数中)

  var handler = myapp.createServerClickHandler('startMailMerge').addCallbackElement(lb).addCallbackElement(name_box).addCallbackElement(bcc_box).addCallbackElement(lf); 

并finaly编辑函数Gmail.sendEmail

  GmailApp.sendEmail(rowData.emailAddress,emailSubject,emailText,
{name:e.parameter.name,附件:附件,htmlBody:emailText,cc:cc,密件抄送: bcc,inlineImages:inlineImages,来自:e.parameter.from,});

这会在邮件菜单中添加一个下拉列表,您可以在其中选择已注册的别名。 p>

Question: Is there a way to override the account email address and replace it with a plus address on the same account?

I'm using the GmailApp.sendEmail() method in Google Apps.

The account e-mail address is a non-plus (obviously) address, but I use several plus addresses to filter messages into categories.

When I send a message with sendEmail(), it uses the main account address and it does not appear that there is a way to change this for a script.

While I can set the "name" for the account, I'd like to set the from address to a plus version of the account address.

(I remember running into this same issue with the Calendar user interface.)

So, I also tried setting a replyTo address using the advanced parameters. (This is not the way I'd prefer to do it.)

The replyTo parameter obviously accepts the address and the message that is sent contains the reply-to header. I've include the header lines below with 'example' replacing the account address.

Delivered-To: example+test@gmail.com

Reply-To: Richard Michael <example+pch@gmail.com>

From: Richard Michael <example@gmail.com>
To: example+test@gmail.com

When I use the Reply button in Gmail, however, the 'To' address that loads in the form is example+test@gmail.com which is neither of the possibilities I would expect. (It should be the Reply-to or, at worst, the From address.) The From address in the reply form is example@gmail.com, which is expected (but also the reason I want to 'send' from a plus address).

I've repeated this several times with the same result.

Of course, Gmail also allows you to 'send' from foreign accounts as well in the user interface after you've performed a validation check. So, you can't send from those addresses either.

解决方案

You have to use the parameter from: in the methode GmailApp.sendEmail.

Example

GmailApp.sendEmail('example@exapmle.com', 'Testmail', 'Hello Richard',
                        {name: 'Richard Michel', from: 'example+pch@gmail.com',}); 

I'm using Mail Merge HD and i edited the code a little.

In function fnMailmerge() i added the lines

  top_panel.add(myapp.createLabel("Please select your alias"));
  var lf = myapp.createListBox(false).setWidth(250).setName('from').addItem("Select aliases...").setVisibleItemCount(1);

  for (var i = 0; i < aliases.length; i++) {
   lf.addItem(aliases[i]);
  }

  top_panel.add(lf);

, added the last statement to this line (in the same function)

var handler = myapp.createServerClickHandler('startMailMerge').addCallbackElement(lb).addCallbackElement(name_box).addCallbackElement(bcc_box).addCallbackElement(lf);

and finaly editet the function Gmail.sendEmail

 GmailApp.sendEmail(rowData.emailAddress, emailSubject, emailText,
                        {name: e.parameter.name, attachments: attachments, htmlBody: emailText, cc: cc, bcc: bcc, inlineImages: inlineImages, from: e.parameter.from,});

This adds a dropdown list to the Mail Menu, where you can chose from your registered Aliases.

这篇关于GmailApp.sendEmail()来自Plus地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 06:36