本文整理汇总了C++中MailMessage::setContent方法的典型用法代码示例。如果您正苦于以下问题:C++ MailMessage::setContent方法的具体用法?C++ MailMessage::setContent怎么用?C++ MailMessage::setContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailMessage
的用法示例。
在下文中一共展示了MailMessage::setContent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSendFailed
void SMTPClientSessionTest::testSendFailed()
{
DialogServer server;
server.addResponse("220 localhost SMTP ready");
server.addResponse("250 Hello localhost");
server.addResponse("250 OK");
server.addResponse("250 OK");
server.addResponse("354 Send data");
server.addResponse("500 Error");
server.addResponse("221 Bye");
SMTPClientSession session("localhost", server.port());
session.login("localhost");
MailMessage message;
message.setSender("[email protected]");
message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Jane Doe"));
message.setSubject("Test Message");
message.setContent("Hello\r\nblah blah\r\n\r\nJohn\r\n");
server.clearCommands();
try
{
session.sendMessage(message);
fail("internal error - must throw");
}
catch (SMTPException&)
{
}
session.close();
}
示例2: main
int main (int argc, char **argv)
{
try
{
MailMessage msg;
msg.addRecipient (MailRecipient (MailRecipient::PRIMARY_RECIPIENT,
"[email protected]",
"Alice Moralis"));
msg.addRecipient (MailRecipient (MailRecipient::CC_RECIPIENT,
"[email protected]",
"Patrick Kilpatrick"));
msg.addRecipient (MailRecipient (MailRecipient::BCC_RECIPIENT,
"[email protected]",
"Michael Carmichael"));
msg.setSender ("Roy Kilroy <[email protected]>");
msg.setSubject ("Rosetta Code");
msg.setContent ("Sending mail from C++ using POCO C++ Libraries");
SMTPClientSession smtp ("mail.example.com"); // SMTP server name
smtp.login ();
smtp.sendMessage (msg);
smtp.close ();
std::cerr << "Sent mail successfully!" << std::endl;
}
catch (std::exception &e)
{
std::cerr << "failed to send mail: " << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例3: ts
void MailMessageTest::testWriteBase64()
{
MailMessage message;
MailRecipient r1(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "John Doe");
message.addRecipient(r1);
message.setSubject("Test Message");
message.setSender("[email protected]");
message.setContent(
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n",
MailMessage::ENCODING_BASE64
);
Timestamp ts(0);
message.setDate(ts);
std::ostringstream str;
message.write(str);
std::string s = str.str();
assert (s ==
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
"Content-Type: text/plain\r\n"
"Subject: Test Message\r\n"
"From: [email protected]\r\n"
"Content-Transfer-Encoding: base64\r\n"
"To: John Doe <[email protected]>\r\n"
"\r\n"
"SGVsbG8sIHdvcmxkIQ0KVGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBNYWlsTWVzc2FnZSBjbGFz\r\n"
"cy4NCg=="
);
}
示例4: testSend
void SMTPClientSessionTest::testSend()
{
DialogServer server;
server.addResponse("220 localhost SMTP ready");
server.addResponse("250 Hello localhost");
server.addResponse("250 OK");
server.addResponse("250 OK");
server.addResponse("354 Send data");
server.addResponse("250 OK");
server.addResponse("221 Bye");
SMTPClientSession session("localhost", server.port());
session.login("localhost");
MailMessage message;
message.setSender("[email protected]");
message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Jane Doe"));
message.setSubject("Test Message");
message.setContent("Hello\r\nblah blah\r\n\r\nJohn\r\n");
server.clearCommands();
session.sendMessage(message);
std::string cmd = server.popCommandWait();
assert (cmd == "MAIL FROM: <[email protected]>");
cmd = server.popCommandWait();
assert (cmd == "RCPT TO: <[email protected]>");
cmd = server.popCommandWait();
assert (cmd == "DATA");
cmd = server.popCommandWait();
assert (cmd.substr(0, 4) == "Date");
cmd = server.popCommandWait();
assert (cmd == "Content-Type: text/plain");
cmd = server.popCommandWait();
assert (cmd == "From: [email protected]");
cmd = server.popCommandWait();
assert (cmd == "Subject: Test Message");
cmd = server.popCommandWait();
assert (cmd == "Content-Transfer-Encoding: quoted-printable");
cmd = server.popCommandWait();
assert (cmd == "To: Jane Doe <[email protected]>");
cmd = server.popCommandWait();
assert (cmd == "Hello");
cmd = server.popCommandWait();
assert (cmd == "blah blah");
cmd = server.popCommandWait();
assert (cmd == "John");
cmd = server.popCommandWait();
assert (cmd == ".");
session.close();
}
示例5: testWriteQP
void MailMessageTest::testWriteQP()
{
MailMessage message;
MailRecipient r1(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "John Doe");
MailRecipient r2(MailRecipient::CC_RECIPIENT, "[email protected]", "Jane Doe");
MailRecipient r3(MailRecipient::BCC_RECIPIENT, "[email protected]", "Frank Foo");
MailRecipient r4(MailRecipient::BCC_RECIPIENT, "[email protected]", "Bernie Bar");
message.addRecipient(r1);
message.addRecipient(r2);
message.addRecipient(r3);
message.addRecipient(r4);
message.setSubject("Test Message");
message.setSender("[email protected]");
message.setContent(
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n"
"To test the quoted-printable encoding, we'll put an extra long line here. This should be enough.\r\n"
"And here is some more =fe.\r\n"
);
Timestamp ts(0);
message.setDate(ts);
assert (!message.isMultipart());
std::ostringstream str;
message.write(str);
std::string s = str.str();
assert (s ==
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
"Content-Type: text/plain\r\n"
"Subject: Test Message\r\n"
"From: [email protected]\r\n"
"Content-Transfer-Encoding: quoted-printable\r\n"
"To: John Doe <[email protected]>\r\n"
"CC: Jane Doe <[email protected]>\r\n"
"\r\n"
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n"
"To test the quoted-printable encoding, we'll put an extra long line here. T=\r\n"
"his should be enough.\r\n"
"And here is some more =3Dfe.\r\n"
);
}
示例6: testWriteManyRecipients
void MailMessageTest::testWriteManyRecipients()
{
MailMessage message;
MailRecipient r1(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "John Doe");
MailRecipient r2(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Jane Doe");
MailRecipient r3(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Frank Foo");
MailRecipient r4(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Bernie Bar");
MailRecipient r5(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "Joe Spammer");
message.addRecipient(r1);
message.addRecipient(r2);
message.addRecipient(r3);
message.addRecipient(r4);
message.addRecipient(r5);
message.setSubject("Test Message");
message.setSender("[email protected]");
message.setContent(
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n",
MailMessage::ENCODING_8BIT
);
Timestamp ts(0);
message.setDate(ts);
std::ostringstream str;
message.write(str);
std::string s = str.str();
assert (s ==
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
"Content-Type: text/plain\r\n"
"Subject: Test Message\r\n"
"From: [email protected]\r\n"
"Content-Transfer-Encoding: 8bit\r\n"
"To: John Doe <[email protected]>, Jane Doe <[email protected]>, \r\n"
"\tFrank Foo <[email protected]>, Bernie Bar <[email protected]>, \r\n"
"\tJoe Spammer <[email protected]>\r\n"
"\r\n"
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n"
);
}
示例7: Test_MailMessage
void Test_MailMessage()
{
std::string sender("[email protected]");
std::string recipient("[email protected]");
std::string subject("Generated email");
std::string content = "Hi ";
content += recipient;
content += ",\n\n";
content += "Have a good day!\n\n";
content += "Regards,\n";
content += "A-Team";
std::string attachment("C:\\DSC.jpg");
MailMessage message;
message.setSender( sender );
message.addRecipient( MailRecipient(MailRecipient::PRIMARY_RECIPIENT, recipient) );
message.setSubject( subject );
message.setContent( content );
message.addAttachment( attachment );
send(message);
}
示例8: main
//.........这里部分代码省略.........
obConversion.SetInFormat(format.c_str());
obConversion.ReadFile(&obMol, (job_path / ("ligand." + format)).string());
const auto num_atoms = obMol.NumAtoms();
// obMol.AddHydrogens(); // Adding hydrogens does not seem to affect SMARTS matching.
// Classify subset atoms.
array<vector<int>, num_subsets> subsets;
for (size_t k = 0; k < num_subsets; ++k)
{
auto& subset = subsets[k];
subset.reserve(num_atoms);
OBSmartsPattern smarts;
smarts.Init(SubsetSMARTS[k]);
smarts.Match(obMol);
for (const auto& map : smarts.GetMapList())
{
subset.push_back(map.front());
}
}
const auto& subset0 = subsets.front();
// Check user-provided ligand validity.
if (subset0.empty())
{
// Record job completion time stamp.
const auto millis_since_epoch = duration_cast<std::chrono::milliseconds>(system_clock::now().time_since_epoch()).count();
conn.update(collection, BSON("_id" << _id), BSON("$set" << BSON("done" << Date_t(millis_since_epoch))));
// Send error notification email.
cout << local_time() << "Sending an error notification email to " << email << endl;
MailMessage message;
message.setSender("usr <[email protected]>");
message.setSubject("Your usr job has failed");
message.setContent("Description: " + job["description"].String() + "\nSubmitted: " + to_simple_string(ptime(epoch, boost::posix_time::milliseconds(job["submitted"].Date().millis))) + " UTC\nFailed: " + to_simple_string(ptime(epoch, boost::posix_time::milliseconds(millis_since_epoch))) + " UTC\nReason: failed to parse the provided ligand.");
message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, email));
SMTPClientSession session("137.189.91.190");
session.login();
session.sendMessage(message);
session.close();
continue;
}
// Calculate the four reference points.
const auto n = subset0.size();
const auto v = 1.0 / n;
array<vector3, num_references> references{};
auto& ctd = references[0];
auto& cst = references[1];
auto& fct = references[2];
auto& ftf = references[3];
for (const auto i : subset0)
{
ctd += obMol.GetAtom(i)->GetVector();
}
ctd *= v;
double cst_dist = numeric_limits<double>::max();
double fct_dist = numeric_limits<double>::lowest();
double ftf_dist = numeric_limits<double>::lowest();
for (const auto i : subset0)
{
const auto& a = obMol.GetAtom(i)->GetVector();
const auto this_dist = a.distSq(ctd);
if (this_dist < cst_dist)
{
cst = a;
cst_dist = this_dist;