BOOL CMailMessage::EncodeHeader() { CString sTo; CString sDate; if( GetNumRecipients() <= 0 ) return FALSE; m_sHeader = ""; // Clear it // Get the recipients into a single string sTo = ""; CString sEmail = ""; CString sFriendly = ""; for( int i = 0; i < GetNumRecipients(); i++ ) { GetRecipient( sEmail, sFriendly, i ); sTo += ( i > 0 ? "," : "" ); sTo += sFriendly; sTo += "<"; sTo += sEmail; sTo += ">"; } m_tDateTime = m_tDateTime.GetCurrentTime(); // Format: Mon, 01 Jun 98 01:10:30 GMT sDate = m_tDateTime.Format( "%a, %d %b %y %H:%M:%S %Z" ); m_sHeader.Format( "Date: %s\r\n"\ "From: %s\r\n"\ "To: %s\r\n"\ "Subject: %s\r\n", // Include other extension lines if desired (LPCTSTR)sDate, (LPCTSTR)m_sFrom, (LPCTSTR)sTo, (LPCTSTR)m_sSubject); return TRUE; }
// Create header as per RFC 822 // void CMailMessage::prepare_header() { CString sTemp; sTemp = _T( "" ); // From: sTemp = _T( "From: " ) + m_sFrom; add_header_line( (LPCTSTR)sTemp ); // To: sTemp = _T( "To: " ); CString sEmail = _T( "" ); CString sFriendly = _T( "" ); for( int i = 0; i < GetNumRecipients(); i++ ) { GetRecipient( sEmail, sFriendly, i ); sTemp += ( i > 0 ? _T( "," ) : _T( "" ) ); sTemp += sFriendly; sTemp += _T( "<" ); sTemp += sEmail; sTemp += _T( ">" ); } add_header_line( (LPCTSTR)sTemp ); //*** Begin <JFO> { sTemp = _T( "Cc: " ); CString sEmail = _T( "" ); CString sFriendly = _T( "" ); for( int i = 0; i < GetNumRecipients(CC); i++ ) { GetRecipient( sEmail, sFriendly, i, CC ); sTemp += ( i > 0 ? _T( "," ) : _T( "" ) ); sTemp += sFriendly; sTemp += _T( "<" ); sTemp += sEmail; sTemp += _T( ">" ); } add_header_line( (LPCTSTR)sTemp ); //*** No BCC informations added..of course ;) } //*** End // Date: m_tDateTime = m_tDateTime.GetCurrentTime(); // Format: Mon, 01 Jun 98 01:10:30 GMT sTemp = _T( "Date: " ); sTemp += m_tDateTime.Format( "%a, %d %b %y %H:%M:%S %Z" ); add_header_line( (LPCTSTR)sTemp ); // Subject: sTemp = _T( "Subject: " ) + m_sSubject; add_header_line( (LPCTSTR)sTemp ); // X-Mailer sTemp = _T( "X-Mailer: " ) + m_sMailerName; add_header_line( (LPCTSTR)sTemp ); }