当前位置: 首页>>代码示例>>C++>>正文


C++ MailMessage类代码示例

本文整理汇总了C++中MailMessage的典型用法代码示例。如果您正苦于以下问题:C++ MailMessage类的具体用法?C++ MailMessage怎么用?C++ MailMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MailMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: session

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();
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:30,代码来源:SMTPClientSessionTest.cpp

示例2: handleMessage

UtlBoolean EmailSendTask::handleMessage( OsMsg& rMsg )
{
   UtlBoolean handled = FALSE;
   AsynchEmailMsg* pEmailMsg = dynamic_cast <AsynchEmailMsg*> ( &rMsg );

   MailMessage msg       = pEmailMsg->getMessage();

   switch ( rMsg.getMsgType() )
   {
   case OsMsg::OS_EVENT:
   {
      UtlString response = msg.Send();
      if (!response.isNull())
      {
         if (response.length() > 0)
         {
            OsSysLog::add(FAC_ALARM, PRI_ERR, "EmailSendTask: "
                  " Error sending e-mail: response %s", response.data());
         }
      }
      handled = TRUE;
      break;
   }

   default:
      OsSysLog::add(FAC_ALARM, PRI_CRIT,
                    "EmailSendTask::handleMessage: '%s' unhandled message type %d.%d",
                    mName.data(), rMsg.getMsgType(), rMsg.getMsgSubType());
      break;
   }

   return handled;
}
开发者ID:LordGaav,项目名称:sipxecs,代码行数:33,代码来源:EmailSendTask.cpp

示例3: data

void WorldSession::HandleReturnToSender(WorldPacket & recv_data )
{
	uint64 mailbox;
	uint32 message_id;
	recv_data >> mailbox >> message_id;

	WorldPacket data(SMSG_SEND_MAIL_RESULT, 12);
	data << message_id << uint32(MAIL_RES_RETURNED_TO_SENDER);

	MailMessage * msg = _player->m_mailBox->GetMessage(message_id);
	if(msg == 0 || msg->Expired())
	{
		data << uint32(MAIL_ERR_INTERNAL_ERROR);
		SendPacket(&data);

		return;
	}
	if(msg->returned_flag)
	{
		data << uint32(MAIL_ERR_INTERNAL_ERROR);
		SendPacket(&data);

		return;
	}

	sMailSystem.ReturnToSender(msg);

	// finish the packet
	data << uint32(MAIL_OK);
	SendPacket(&data);
}
开发者ID:Chameleo,项目名称:Hearthstone,代码行数:31,代码来源:MailSystem.cpp

示例4: UpdateMessages

void MailSystem::UpdateMessages()
{
	if((++loopcount % 1200))
		return;

	QueryResult *result = CharacterDatabase.Query("SELECT * FROM mailbox WHERE expiry_time > 0 and expiry_time <= %u and deleted_flag = 0",(uint32)UNIXTIME);

	if(!result)
		return;

	MailMessage msg;
	do 
	{
		if (msg.LoadFromDB(result->Fetch()))
		{
			if (/*msg.Expired() &&*/ msg.items.size() == 0 && msg.money == 0)
			{
				if(msg.copy_made)
				{
					msg.deleted_flag = true;
					msg.SaveToDB();
				} else
				{
					CharacterDatabase.WaitExecute("DELETE FROM mailbox WHERE message_id = %u", msg.message_id);
				}
			} else
			{
				ReturnToSender(&msg);
			}

		}
	} while(result->NextRow());
	delete result;
}
开发者ID:Chameleo,项目名称:Hearthstone,代码行数:34,代码来源:MailSystem.cpp

示例5: istr

void MailMessageTest::testReadQP()
{
	std::istringstream istr(
		"Content-Transfer-Encoding: quoted-printable\r\n"
		"Content-Type: text/plain\r\n"
		"Date: Thu, 1 Jan 1970 00:00:00 GMT\r\n"
		"From: [email protected]\r\n"
		"Subject: Test Message\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"
		"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"
	);
	
	MailMessage message;
	message.read(istr);
	
	assert (message.getSender() == "[email protected]");
	assert (message.getContentType() == "text/plain");
	assert (message.getContent() == 
		"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"
	);
}
开发者ID:alexdarling,项目名称:roadrunner,代码行数:29,代码来源:MailMessageTest.cpp

示例6: removeMail

bool Acount::removeMail(const int& index)
{
	MailMessage mail;
	bool remove = _mailBox.remove(index, mail);
	_size -= mail.getSize();
	if (remove)
		_msgCount--;
	return remove;
}
开发者ID:Tavorc,项目名称:Mailbox,代码行数:9,代码来源:Acount.cpp

示例7: setMessage

void MessageDetailsModel::setMessage(const MailMessage& message)
{
  clear();
  beginInsertRows(QModelIndex(), 0,
                  message.getHeaders().size() + message.getBody().size());
  this->message = message;
  endInsertRows();
  reset();
}
开发者ID:netconstructor,项目名称:email_archiver,代码行数:9,代码来源:messagedetailsmodel.cpp

示例8: session

void POP3ClientSessionTest::testRetrieveMessages()
{
	DialogServer server;
	server.addResponse("+OK POP3 Ready...");
	server.addResponse("+OK USER");
	server.addResponse("+OK PASS");
	server.addResponse(
		"+OK Here comes the message\r\n"
		"From: [email protected]\r\n"
		"To: [email protected]\r\n"
		"Subject: test\r\n"
		"\r\n"
		"."
	);
	server.addResponse(
		"+OK Here comes the message\r\n"
		"From: [email protected]\r\n"
		"To: [email protected]\r\n"
		"Subject: test\r\n"
		"\r\n"
		"Hello Jane,\r\n"
		"\r\n"
		"blah blah blah...\r\n"
		"....\r\n"
		"\r\n"
		"Yours, John\r\n"
		"."
	);
	server.addResponse("+OK QUIT");
	POP3ClientSession session("localhost", server.port());
	session.login("user", "secret");
	server.clearCommands();
	MessageHeader header;
	session.retrieveHeader(1, header);
	std::string cmd = server.popCommand();
	assert (cmd == "TOP 1 0");
	assert (header.get("From") == "[email protected]");
	assert (header.get("To") == "[email protected]");
	assert (header.get("Subject") == "test");

	MailMessage message;
	session.retrieveMessage(2, message);
	cmd = server.popCommand();
	assert (cmd == "RETR 2");

	assert (message.getContent() ==
		"Hello Jane,\r\n"
		"\r\n"
		"blah blah blah...\r\n"
		"...\r\n"
		"\r\n"
		"Yours, John\r\n"
	);
	session.close();
}
开发者ID:12307,项目名称:poco,代码行数:55,代码来源:POP3ClientSessionTest.cpp

示例9: TEST_F

TEST_F(ReportMailerTest, CanConstructMailMessage)
{
    string toAddress = "[email protected]";
    StubReport report;

    MailMessage message = ReportMailer::ConstructMailMessageTo(toAddress, &report);

    ASSERT_THAT(message.To()[0], Eq(toAddress));
    ASSERT_THAT(message.Subject(), Eq(report.Name()));
    ASSERT_THAT(message.Content(), Eq(report.Text()));
    ASSERT_THAT(message.From(), Eq("[email protected]"));
}
开发者ID:nstoker,项目名称:mcpp-tdd,代码行数:12,代码来源:ReportMailerTest.cpp

示例10: GetMessage

void Mailbox::OnMessageCopyDeleted(uint32 msg_id)
{
	MailMessage * msg = GetMessage(msg_id);
	if(msg == 0) return;

	msg->copy_made = false;

	if(msg->deleted_flag)   // we've deleted from inbox
		DeleteMessage(msg);   // wipe the message
	else
		msg->SaveToDB();
}
开发者ID:Chameleo,项目名称:Hearthstone,代码行数:12,代码来源:MailSystem.cpp

示例11: r1

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);
}
开发者ID:alexdarling,项目名称:roadrunner,代码行数:57,代码来源:MailMessageTest.cpp

示例12: Load

void Mailbox::Load(QueryResult * result)
{
	if(!result)
		return;

	MailMessage msg;
	do 
	{
		if (msg.LoadFromDB(result->Fetch()))
		{
			AddMessage(&msg);// Add to the mailbox
		}
	} while(result->NextRow());
}
开发者ID:Chameleo,项目名称:Hearthstone,代码行数:14,代码来源:MailSystem.cpp

示例13: send

void send(const MailMessage& msg)
{
    /// Just a skeleton.
    /// Assuming that there is a third party send
    /// API which is responsible for sending email.
    print( "Sender: " + msg.getSender() );

    print("Recipients:");
    MailMessage::Recipients recipients = msg.getRecipients();
    for ( auto start = recipients.begin(); start != recipients.end(); ++start )
        print( (*start).getAddress() );

    print("Subject: " + msg.getSubject() );
    print("Content: " + msg.getContent() );
}
开发者ID:rajendrauppal,项目名称:design,代码行数:15,代码来源:Client.cpp

示例14: sender

void SMTPClientSession::sendCommands(const MailMessage& message, const Recipients* pRecipients)
{
	std::string response;
	int status = 0;
	const std::string& fromField = message.getSender();
	std::string::size_type emailPos = fromField.find('<');
	if (emailPos == std::string::npos)
	{
		std::string sender("<");
		sender.append(fromField);
		sender.append(">");
		status = sendCommand("MAIL FROM:", sender, response);
	}
	else
	{
		status = sendCommand("MAIL FROM:", fromField.substr(emailPos, fromField.size() - emailPos), response);
	}

	if (!isPositiveCompletion(status)) throw SMTPException("Cannot send message", response, status);
	
	std::ostringstream recipient;
	if (pRecipients)
	{
		for (Recipients::const_iterator it = pRecipients->begin(); it != pRecipients->end(); ++it)
		{
			recipient << '<' << *it << '>';
			int status = sendCommand("RCPT TO:", recipient.str(), response);
			if (!isPositiveCompletion(status)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, status);
			recipient.str("");
		}
	}
	else
	{
		for (MailMessage::Recipients::const_iterator it = message.recipients().begin(); it != message.recipients().end(); ++it)
		{
			recipient << '<' << it->getAddress() << '>';
			int status = sendCommand("RCPT TO:", recipient.str(), response);
			if (!isPositiveCompletion(status)) throw SMTPException(std::string("Recipient rejected: ") + recipient.str(), response, status);
			recipient.str("");
		}
	}

	status = sendCommand("DATA", response);
	if (!isPositiveIntermediate(status)) throw SMTPException("Cannot send message data", response, status);
}
开发者ID:12307,项目名称:poco,代码行数:45,代码来源:SMTPClientSession.cpp

示例15: 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;
}
开发者ID:Anatolt,项目名称:RosettaCodeData,代码行数:35,代码来源:send-email.cpp


注:本文中的MailMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。