本文整理汇总了C++中MailMessage::setDate方法的典型用法代码示例。如果您正苦于以下问题:C++ MailMessage::setDate方法的具体用法?C++ MailMessage::setDate怎么用?C++ MailMessage::setDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailMessage
的用法示例。
在下文中一共展示了MailMessage::setDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ts
void MailMessageTest::testWrite8Bit()
{
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_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]>\r\n"
"\r\n"
"Hello, world!\r\n"
"This is a test for the MailMessage class.\r\n"
);
}
示例2: testWriteMultiPart
void MailMessageTest::testWriteMultiPart()
{
MailMessage message;
MailRecipient r1(MailRecipient::PRIMARY_RECIPIENT, "[email protected]", "John Doe");
message.addRecipient(r1);
message.setSubject("Test Message");
message.setSender("[email protected]");
Timestamp ts(0);
message.setDate(ts);
message.addContent(new StringPartSource("Hello World!\r\n", "text/plain"), MailMessage::ENCODING_8BIT);
StringPartSource* pSPS = new StringPartSource("This is some binary data. Really.", "application/octet-stream", "sample.dat");
pSPS->headers().set("Content-ID", "abcd1234");
message.addAttachment("sample", pSPS);
assert (message.isMultipart());
std::ostringstream str;
message.write(str);
std::string s = str.str();
std::string rawMsg(
"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
"Content-Type: multipart/mixed; boundary=$\r\n"
"Subject: Test Message\r\n"
"From: [email protected]\r\n"
"To: John Doe <[email protected]>\r\n"
"Mime-Version: 1.0\r\n"
"\r\n"
"--$\r\n"
"Content-Type: text/plain\r\n"
"Content-Transfer-Encoding: 8bit\r\n"
"Content-Disposition: inline\r\n"
"\r\n"
"Hello World!\r\n"
"\r\n"
"--$\r\n"
"Content-ID: abcd1234\r\n"
"Content-Type: application/octet-stream; name=sample\r\n"
"Content-Transfer-Encoding: base64\r\n"
"Content-Disposition: attachment; filename=sample.dat\r\n"
"\r\n"
"VGhpcyBpcyBzb21lIGJpbmFyeSBkYXRhLiBSZWFsbHku\r\n"
"--$--\r\n"
);
std::string::size_type p1 = s.find('=') + 1;
std::string::size_type p2 = s.find('\r', p1);
std::string boundary(s, p1, p2 - p1);
std::string msg;
for (std::string::const_iterator it = rawMsg.begin(); it != rawMsg.end(); ++it)
{
if (*it == '$')
msg += boundary;
else
msg += *it;
}
assert (s == msg);
}
示例3: 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"
);
}
示例4: 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"
);
}