• 大小: 10.87MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-10
  • 语言: C/C++
  • 标签:

资源简介

VC++实现收发电子邮件 里面附有详细的代码 可供参考

资源截图

代码片段和文件信息

// MailMessage.cpp: implementation of the CMailMessage class.
// Copyright (c) 1998 Wes Clyburn
//
// Modified to have Header and Body handling in this class rather than in any
// class that uses instances of CMailMessage.
// Copyright (c) 1998 Michael Krebs
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “MailMessage.h“

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMailMessage::CMailMessage()
{
m_sBody=_T(““);
m_sHeader=_T(““);
}

CMailMessage::~CMailMessage()
{

}

BOOL CMailMessage::AddRecipient( LPCTSTR szEmailAddress LPCTSTR szFriendlyName)
{
ASSERT( szEmailAddress != NULL );
ASSERT( szFriendlyName != NULL );
CRecipient to;
to.m_sEmailAddress = szEmailAddress;
to.m_sFriendlyName = szFriendlyName;
m_Recipients.Add( to );
return TRUE;
}

// sEmailAddress and sFriendlyName are OUTPUT parameters.
// If the function fails it will return FALSE and the OUTPUT
// parameters will not be touched.
BOOL CMailMessage::GetRecipient(CString & sEmailAddress CString & sFriendlyName int nIndex)
{
CRecipient to;
if( nIndex < 0 || nIndex > m_Recipients.GetUpperBound() )
return FALSE;
to = m_Recipients[ nIndex ];
sEmailAddress = to.m_sEmailAddress;
sFriendlyName = to.m_sFriendlyName;
return TRUE;
}

int CMailMessage::GetNumRecipients()
{
return m_Recipients.GetSize();
}

BOOL CMailMessage::AddMultipleRecipients(LPCTSTR szRecipients )
{
TCHAR* buf;
UINT pos;
UINT start;
CString sTemp;
CString sEmail;
CString sFriendly;
UINT length;
int nMark;
int nMark2;

ASSERT( szRecipients != NULL );

// Add Recipients
//
length = strlen( szRecipients );
buf = new TCHAR[ length + 1 ]; // Allocate a work area (don‘t touch parameter itself)
strcpy( buf szRecipients );
for( pos = 0 start = 0; pos <= length; pos++ )
{
if( buf[ pos ] == ‘;‘ ||
buf[ pos ] == 0 )
{
// First pick apart the sub-strings (separated by ‘;‘)
//  Store it in sTemp.
//
buf[ pos ] = 0; // Redundant when at the end of string but who cares.
sTemp = &buf[ start ];

// Now divide the substring into friendly names and e-mail addresses.
//
nMark = sTemp.Find( ‘<‘ );
if( nMark >= 0 )
{
sFriendly = sTemp.Left( nMark );
nMark2 = sTemp.Find( ‘>‘ );
if( nMark2 < nMark )
{
delete[] buf;
return FALSE;
}
// End of mark at closing bracket or end of string
nMark2 > -1 ? nMark2 = nMark2 : nMark2 = sTemp.GetLength() - 1;
sEmail = sTemp.Mid( nMark + 1 nMark2 - (nMark + 1) );
}
else
{
sEmail = sTemp;
sFriendly = ““;
}
AddRecipient( sEmail sFriendly );
start = pos + 1;
}
}
delete[] buf;
retu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7364  1998-11-30 02:07  编程实现收发电子邮件\MyEmailClient\MailMessage.cpp

     文件       1541  1998-11-30 02:07  编程实现收发电子邮件\MyEmailClient\MailMessage.h

     文件      37244  2008-05-27 10:00  编程实现收发电子邮件\MyEmailClient\MyEmailClient.aps

     文件       1912  2008-05-27 10:22  编程实现收发电子邮件\MyEmailClient\MyEmailClient.clw

     文件       2255  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\MyEmailClient.cpp

     文件       4659  2002-06-27 09:50  编程实现收发电子邮件\MyEmailClient\MyEmailClient.dsp

     文件        551  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\MyEmailClient.dsw

     文件       1401  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\MyEmailClient.h

     文件      73728  2008-05-27 10:22  编程实现收发电子邮件\MyEmailClient\MyEmailClient.opt

     文件       1261  2008-05-27 10:22  编程实现收发电子邮件\MyEmailClient\MyEmailClient.plg

     文件       6555  2008-05-27 10:00  编程实现收发电子邮件\MyEmailClient\MyEmailClient.rc

     文件        891  2011-08-13 10:24  编程实现收发电子邮件\MyEmailClient\MyEmailClient.sln

    ..A..H.     10240  2012-04-04 21:18  编程实现收发电子邮件\MyEmailClient\MyEmailClient.suo

     文件       8793  2011-08-13 10:24  编程实现收发电子邮件\MyEmailClient\MyEmailClient.vcproj

     文件       1427  2011-08-13 10:25  编程实现收发电子邮件\MyEmailClient\MyEmailClient.vcproj.PC-201107222103.Administrator.user

     文件       1409  2010-10-25 09:01  编程实现收发电子邮件\MyEmailClient\MyEmailClient.vcproj.WANGHH.Administrator.user

     文件       6064  2008-05-27 10:22  编程实现收发电子邮件\MyEmailClient\MyEmailClientDlg.cpp

     文件       1563  2002-06-27 09:10  编程实现收发电子邮件\MyEmailClient\MyEmailClientDlg.h

     文件       5304  1998-11-30 02:09  编程实现收发电子邮件\MyEmailClient\POP3.cpp

     文件       1760  1998-11-29 04:50  编程实现收发电子邮件\MyEmailClient\POP3.h

     文件       3705  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\ReadMe.txt

     文件       1150  2002-06-27 09:09  编程实现收发电子邮件\MyEmailClient\resource.h

     文件       5986  1998-11-30 02:05  编程实现收发电子邮件\MyEmailClient\SMTP.cpp

     文件       1806  1998-11-30 02:05  编程实现收发电子邮件\MyEmailClient\SMTP.h

     文件        215  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\StdAfx.cpp

     文件       1102  2002-06-27 08:46  编程实现收发电子邮件\MyEmailClient\StdAfx.h

     文件       2737  2011-08-13 10:24  编程实现收发电子邮件\MyEmailClient\UpgradeLog.xml

     文件   12807168  2012-04-04 21:18  编程实现收发电子邮件\MyEmailClient\MyEmailClient.ncb

     文件       1427  2012-04-04 21:18  编程实现收发电子邮件\MyEmailClient\MyEmailClient.vcproj.GTA-WANGWEIPING.Administrator.user

     文件      10582  2012-04-04 21:10  编程实现收发电子邮件\MyEmailClient\Debug\BuildLog.htm

............此处省略32个文件信息

评论

共有 条评论