我能够发送带有单个附件的电子邮件,但我找不到在单个邮件中发送多个附件的任何内容
try {
SendGrid sendgrid = new SendGrid(SENDGRID_USERNAME, SENDGRID_PASSWORD);
SendGrid.Email email = new SendGrid.Email();
// Get values from edit text to compose email
// TODO: Validate edit texts
email.addTo(mTo);
email.setFrom(mFrom);
email.setSubject(mSubject);
email.setText(mText);
// Attach image
if (mUri != null) {
email.addAttachment(mAttachmentName, mAppContext.getContentResolver().openInputStream(mUri));
}
// Send email, execute http request
SendGrid.Response response = sendgrid.send(email);
mMsgResponse = response.getMessage();
Log.d("SendAppExample", mMsgResponse);
} catch (SendGridException | IOException e) {
Log.e("SendAppExample", e.toString());
}
return null;
}
Run Code Online (Sandbox Code Playgroud) 我试图通过sendgrid发送电子邮件。我有一个自定义域myself@contoso.com。如果我尝试将发件人地址为my1@contoso.com的电子邮件发送到user1@gmail.com,则该电子邮件将通过“通过”传递到gmail。当我尝试通过发自地址将电子邮件发送到selfie@contoso.com时,活动说该电子邮件已发送,但是在Outlook客户中,我没有收到该电子邮件。我可以尝试或做什么?
我已经尝试将contoso.com列入白名单,但没有成功
我正在尝试使用 Sendgrid v3 API 更改现有收件人的电子邮件地址。
使用此示例:更新收件人 [PATCH],我可以更新除电子邮件地址之外的所有内容。但是,如果我输入一个新的电子邮件地址,它将作为新的电子邮件地址插入,而旧的电子邮件地址仍保留在原始收件人处。
API 是否支持此功能?如果支持,是如何实现的?
SendGrid 中的版本控制允许 API 客户端仅通过此处记录的模板 ID 发出模板请求,但是,一次只能“活动”一个模板版本。显然,用于我们的生产应用程序的模板需要始终设置为活动状态,但是如何添加我们在即将发布的版本中使用的新模板版本呢?我如何利用模板版本在我们的测试环境中测试这个“非活动”版本?此处讨论了该问题,但是当您开始关注链接时,它似乎只是关闭并丢失了。
如果无法指定版本控制,那么只剩下几个选项需要创建特定于环境的模板并在发布完成后将它们提升为特定于生产的模板,或者为不同的 SDLC 环境创建单独的帐户并将它们迁移为这一进程向前推进。
此处也讨论了有关语言版本控制的问题,但这确实对我的问题没有帮助。
鉴于 SendGrid 的 API 提供的工具来利用版本控制,最佳实践是什么?拥有不同的 SDLC 步骤命名模板似乎是维护数百个模板的灾难(更不用说每个环境的多个模板了)。在转移到生产时进行测试时,管理多个帐户似乎是一场噩梦。我只是在这里遗漏了一些完全明显的东西吗?
我正在将 Sendgrid 的新 API (v3) 与 Node js + 库@sendgrid/mail和@sendgrid/client.
我想要实现的目标:向我的所有联系人发送每周摘要(除了那些从该组取消订阅的人)。我使用通过 Sendgrid 创建的模板(得益于其 template_id)以及动态模板数据,以使用每周数据填充邮件。
问题:
我可以使用/v3/marketing/singlesends使用模板向所有联系人发送营销活动,但无法使用动态模板数据发送它。
我可以使用模板 + 动态模板数据一次发送一封电子邮件,但为此我需要先检索所有联系人,并且只能从此端点/v3/marketing/contacts检索最后 50 个联系人(他们禁用了分页) 。我可能已经能够从这个端点/contactdb/recipients检索它们,问题是我在他们发布新 API 后创建了我的 Sendgrid 帐户,所以我无法访问它。
关于如何执行此操作有任何想法吗?
当前代码:
1) 配置活动
const sgClient = require('@sendgrid/client')
var params={
'name': 'Weekly Digest #'+nb,
'sender_id': sg_sender_id,
'suppression_group_id': sg_unsub_group_id,
'template_id': id_template,
'dynamicTemplateData': template_params,
//also tried with 'dynamic_template_data' instead, not working
'filter': {'send_to_all': true}
}
let url='/v3/marketing/singlesends/' + campaign_id.toString('base64')
const request = {
method: 'PATCH', …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Sendgrid Node JS 将联系人添加到营销列表
var request = require("request");
var options = { method: 'PUT',
url: 'https://api.sendgrid.com/v3/marketing/contacts',
headers: { authorization: 'Bearer myAPIKEY' },
body: '{"contacts":[{"email": "myMail@gmail.com","unique_name":"myName"}]}' };
request(options, function () {
});
Run Code Online (Sandbox Code Playgroud)
一切正常,但我还想将联系人添加到特定列表中。我阅读了文档,它说我需要添加联系人的 ID。
我在哪里可以找到该信息或如何将联系人添加到特定列表?
谢谢你!
我有一个 sendgrid 帐户,其中包含 7 天的电子邮件历史记录。我尝试使用 api 命令获取这些:
var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "messages?limit=10");
但这给出了响应:
{"errors":[{"message":"authorization required"}]}
我猜 api 密钥不正确,但是当我尝试执行命令时:
var sendgridtask = sendgridclient.RequestAsync(method: SendGrid.SendGridClient.Method.GET, urlPath: "suppression/bounces/" + email);
它不会给出任何错误并响应正确的信息。我检查了 api 密钥,它具有完全访问权限。
我也尝试过:
sendgridclient.AddAuthorization(new KeyValuePair<string, string>("Authorization", $"Bearer {apiKey}"));
但这给出了相同的响应
你知道我做错了什么吗?
我有:
import sendgridClient from '@sendgrid/client'
sendgridClient.setApiKey(process.env.SENDGRID_API_KEY);
const sendgridRequest = {
method: 'PUT',
url: '/v3/marketing/contacts',
body: {
list_ids: [myId],
contacts: [
{
email: req.body.email,
custom_fields: {
[myFieldId]: 'in_free_trial'
}
}
]
}
};
await sendgridClient.request(sendgridRequest);
Run Code Online (Sandbox Code Playgroud)
但是我的 TypeScript 语言服务器给了我一个错误sendgridRequest:
Argument of type '{ method: string; url: string; body: { list_ids: string[]; contacts: { email: any; custom_fields: { e5_T: string; }; }[]; }; }' is not assignable to parameter of type 'ClientRequest'.
Types of property 'method' are incompatible.
Type 'string' is …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用他们为 C# 提供的 SendGrid sdk 将 ics 文件附加到电子邮件中。
这是我的代码:
using SendGrid;
using SendGrid.Helpers.Mail;
----
var client = new SendGridClient(APIKey);
var from = new EmailAddress(email.From);
var to = new EmailAddress(email.To);
var msg = MailHelper.CreateSingleEmail(from, to, "test", "test");
var testcontent = "BEGIN:VCALENDAR" + Environment.NewLine;
testcontent += "PRODID:-//Google Inc//Google Calendar 70.9054//EN" + Environment.NewLine;
testcontent += "VERSION:2.0" + Environment.NewLine;
testcontent += "CALSCALE:GREGORIAN" + Environment.NewLine;
testcontent += "METHOD:REQUEST" + Environment.NewLine;
testcontent += "BEGIN:VEVENT" + Environment.NewLine;
testcontent += "DTSTART:20220418T003000Z" + Environment.NewLine;
testcontent += "DTEND:20220418T010000Z" + Environment.NewLine; …Run Code Online (Sandbox Code Playgroud) 我已经为 sendgrid 设置了一个端点来发送事件通知。但是,服务器设置了基本身份验证,并且事件不会通过,因为它们未经身份验证。如何通过 SendGrid 或白名单 SendGrid 对这些事件 webhook 进行身份验证?
sendgrid-api-v3 ×10
sendgrid ×7
node.js ×3
c# ×2
javascript ×2
android ×1
endpoint ×1
icalendar ×1
typescript ×1
webhooks ×1