这是我的代码:
double result = 0;
Console.Write("Enter First Number: ");
double num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter Second Number: ");
double num2 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter a number from 1 to 3");
string input = Console.ReadLine();
switch (input) {
case "1" :
result = num1 + num2;
break;
case "2":
result = num1 - num2;
break;
case "3":
result = num1 * num2;
break;
default:
Console.WriteLine("\n Next time follow instructions. You can only choose numbers 1 - 4");
break;
}
Console.WriteLine("Result = " + result);
userDetails是具有ID的电子邮件数组。
我之前在nodemailer中使用了几乎相同的代码,并且效果很好。这是nodemailer版本:
userDetails = [{email:'email',id:'id'}]
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey('key');
for (const i in usersDetails) {
const user = usersDetails[i];
const msg = {
from: `ZdajTo<noreply@zdajto.com>`,
to: user.email,
subject: `Dostepne sa nowe zadania z kategorii ${work.category}!`,
html: `<p>Hej! Sprawdz aplikacje ZdajTo! Dostepne sa nowe zadania z kategorii ${work.category}! Aby zrezygnowac z otrzymywania emaili kliknij w <a href="https://Link/${user.id}" target="_blank">ten link</a></p>`,
};
calls.push(sgMail.send(msg).then(() => console.log(`Email sent to ${msg.to}`)).catch(e => console.log(e)));
}
return Promise.all(calls).then(() => console.log('Emails sent')).catch(err => console.log(8, err));
奇怪的是,每次都说for (const i in usersDetails) {
const user = usersDetails[i];
calls.push(mailTransport.sendMail({
from: `ZdajTo <noreply@zdajto.com>`,
to: user.email,
subject: `Dostepne sa nowe zadania z kategorii ${work.category}!`,
html: `<p>Hej! Sprawdz aplikacje ZdajTo! Dostepne sa nowe zadania z kategorii ${work.category}! Aby zrezygnowac z otrzymywania emaili kliknij w <a href="https://Link/${user.id}" target="_blank">ten link</a></p>`,
}).catch(err => console.log(7, err, user.email)));
}
和Emails sent
。没有引发任何错误,但同时SendGrid表示没有请求。知道我想念什么吗?
答案 0 :(得分:1)
我的假设是您收到的响应(202)会触发“已发送消息”部分。但是,它不能保证您的消息将被发送,而只是将其排队处理。在这种情况下,我会与Sendgrid支持人员联系:Sendgrid returns 202 but doesn't send email