• 大小: 44KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: 其他
  • 标签: 电子邮件  POP3  SMTP  

资源简介

VC源码,电子邮件客户端例子,收发邮件,用到POP3和SMTP.

资源截图

代码片段和文件信息

// 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

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-11-10 14:33  收发送电子邮件.POP3SMTP\MyEmailClient\
     文件        9049  2009-05-04 07:06  收发送电子邮件.POP3SMTP\MyEmailClient\ico-arrow.gif
     文件        7364  1998-11-30 02:07  收发送电子邮件.POP3SMTP\MyEmailClient\MailMessage.cpp
     文件        1541  1998-11-30 02:07  收发送电子邮件.POP3SMTP\MyEmailClient\MailMessage.h
     文件       36704  2002-06-27 09:09  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.aps
     文件        1872  2002-06-27 09:50  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.clw
     文件        2255  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.cpp
     文件        4659  2002-06-27 09:50  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.dsp
     文件         551  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.dsw
     文件        1401  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.h
     文件       50688  2002-06-27 09:50  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.opt
     文件        1173  2002-06-27 09:47  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.plg
     文件        6470  2002-06-27 09:09  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClient.rc
     文件        6222  2002-06-27 09:47  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClientDlg.cpp
     文件        1563  2002-06-27 09:10  收发送电子邮件.POP3SMTP\MyEmailClient\MyEmailClientDlg.h
     文件        5304  1998-11-30 02:09  收发送电子邮件.POP3SMTP\MyEmailClient\POP3.cpp
     文件        1760  1998-11-29 04:50  收发送电子邮件.POP3SMTP\MyEmailClient\POP3.h
     文件        3705  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\ReadMe.txt
     目录           0  2014-11-10 14:33  收发送电子邮件.POP3SMTP\MyEmailClient\res\
     文件        1078  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\res\MyEmailClient.ico
     文件         405  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\res\MyEmailClient.rc2
     文件        1150  2002-06-27 09:09  收发送电子邮件.POP3SMTP\MyEmailClient\resource.h
     文件        5986  1998-11-30 02:05  收发送电子邮件.POP3SMTP\MyEmailClient\SMTP.cpp
     文件        1806  1998-11-30 02:05  收发送电子邮件.POP3SMTP\MyEmailClient\SMTP.h
     文件         215  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\StdAfx.cpp
     文件        1102  2002-06-27 08:46  收发送电子邮件.POP3SMTP\MyEmailClient\StdAfx.h

评论

共有 条评论