Beispiel #1
0
DWORD CLotusNote::ItemAddTextList(char *item_name, char *item_value,BOOL duplicate)
{
	if (m_hnote == NULL) return Error_Handle("ItemAddTextList ... failed");
	return CLotusSection::Add_NApi_code_msg(NSFItemAppendTextList(m_hnote,item_name,item_value,MAXWORD,duplicate),SSIZE(m_err_msg),"CLotusNote::ItemAddTextList->NSFItemAppendTextList");
}
void RecipientsHandler::SetNotesRecipients(const HANDLE noteHandle, const std::wstring& recipients, const AbstractRecipient::Location recipientField)
{
	if(0 == noteHandle || recipients.empty())
		return;

	std::string notesRecipientField;
	std::wstring errorMessage;

	switch(recipientField)
	{
	case AbstractRecipient::ENTERED_TO:
		notesRecipientField = MAIL_ENTERSENDTO_ITEM;
		errorMessage = L"Failed to set the enter To Recipients of notes message";
		break;
	case AbstractRecipient::ENTERED_CC:
		notesRecipientField = MAIL_ENTERCOPYTO_ITEM;
		errorMessage = L"Failed to set the enter CC Recipients of notes message";
		break;
	case AbstractRecipient::ENTERED_BCC:
		notesRecipientField = MAIL_ENTERBLINDCOPYTO_ITEM;
		errorMessage = L"Failed to set the enter BCC Recipients of notes message";
		break;
	case AbstractRecipient::SENDTO:
		notesRecipientField = MAIL_SENDTO_ITEM;
		errorMessage = L"Failed to set the To Recipients of notes message";
		break;
	case AbstractRecipient::COPYTO:
		notesRecipientField = MAIL_COPYTO_ITEM;
		errorMessage = L"Failed to set the CC Recipients of notes message";
		break;
	case AbstractRecipient::BLINDCOPYTO:
		notesRecipientField = MAIL_BLINDCOPYTO_ITEM;
		errorMessage = L"Failed to set the BCC Recipients of notes message";
		break;
	default:
		return;
	}

	vector_wstring recipientsVector = Parser::ExtractRecipientsItems(recipients);
	if(recipientsVector.empty())
		return;

	STATUS status = NSFItemSetText(noteHandle, notesRecipientField.c_str(), "", 0);
	if(LNNOERROR != status)
	{
		LOG_WS_ERROR(L"Failed to clear the recipient field. Continue to append items");
	}

    for(vector_wstring::size_type index = 0; index < recipientsVector.size(); ++index)
	{
        std::string recipient = Workshare::Conversions::W22LMBCS(recipientsVector[index].c_str());
		status = NSFItemAppendTextList(noteHandle, notesRecipientField.c_str(), recipient.c_str(), (WORD)recipient.size(), FALSE);
		if(LNNOERROR != status)
        {
			std::wostringstream msg;
            msg << L"Failed to append [" << recipientsVector[index].c_str() << L"] " << L"to the recipient list [" <<  Workshare::Conversions::A22W(notesRecipientField.c_str()).c_str() << L"]" << std::ends;
            LOG_WS_ERROR(msg.str().c_str());
        }
		else
		{
			std::wostringstream msg;
            msg << L"Append [" << recipientsVector[index].c_str() << L"] " << L"to the recipient list [" <<  Workshare::Conversions::A22W(notesRecipientField.c_str()).c_str() << L"]" << std::ends;
            LOG_WS_ERROR(msg.str().c_str());
		}
	}
}