Use VC to send Mail could be very complicated if you programe it yourself
using MAPI!
However there are some share classes on internet that you could use !
You could download it ,and analyse it ,then to use it .You had better make sure
you understand the code before you use it !
I have one which is displayed below.However I couldn't give it to here!========================================================================
ATL COM Object : SimpleEmailClientX 1.3
========================================================================Author: Emmanuel KARTMANN <[email protected]>
Creation Date: November 28th, 1998
Last Modification Date: February 8th, 2000OVERVIEW
========This ATL COM component provides very simple Internet email functionality (SMTP).FEATURES
======== * implement the basics of SMTP, as defined in RFC821 and RFC822
* send plain text email: no attachements, no MIME encoding.
* support multiple recipients (separate email addresses with commas ',')
* support multiple email servers (try next server if email cannot be delivered to a server)
NEW * provides automatic detection of SMTP server (resolve MX record in the DNS, using COMponent SimpleDNSResolver)
* provide extended error information (ISupportErrorInfo and IErrorInfo are implemented)
* provide very small executable: 44 Ko (MinSize) to 144 Ko (MinDependency)
* require no Graphical User Interface: the component can be used in non-GUI applications,
like a Windows NT Service.
* run on Windows NT 4.0, Windows 95 and Windows 98
* compile with VC++ 6.0 SP3USAGE
=====To use this component:
* create an instance of the component,
* call method SendEmail from interface ISimpleEmailClientX,
* handle errors (try/catch in C++)SAMPLE CODE (VC++)
================== // Import smart pointer definition
#import "SimpleEmailClient.dll" no_namespace // Create smart pointer object
ISimpleEmailClientXPtr pSimpleEmailClientX; // =======================================================================
// Initialize COM (This should be called at thread startup)
// =======================================================================
HRESULT hResult = CoInitialize(NULL);
if (FAILED(hResult)) {
ErrorDialogBox("Cannot initialize COM: \n", hResult);
return; // Failed
}
// =======================================================================
// Create instance of the component to test
// =======================================================================
try
{
HRESULT hResult = S_OK;
// Create object
hResult = pSimpleEmailClientX.CreateInstance("Emmanuel.SimpleEmailClientX.1");
if (FAILED(hResult)) {
ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", hResult);
}
}
catch (_com_error &e)
{
ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", e);
} // =======================================================================
// Call method of component
// =======================================================================
try
{
HRESULT hResult = S_OK;
hResult = pSimpleEmailClientX->SendEmail(_bstr_t(m_szFrom), _bstr_t(m_szTo), _bstr_t(m_szSubject), _bstr_t(m_szBody), _bstr_t(m_szServerName));
if (FAILED(hResult)) {
ErrorDialogBox("Failure while executing method SendMail: \n", hResult);
}
}
catch (_com_error &e)
{
ErrorDialogBox("Failure while executing method SendMail: \n", e);
} // =======================================================================
// UnInitialize COM (This should be called at thread exit)
// =======================================================================
CoUninitialize();
Please refer to the test project in subdirectory "TestSimpleEmailClient" for a full example.SAMPLE CODE (VBScript)
====================== Dim oSMTP Set oSMTP = CreateObject("Emmanuel.SimpleEmailClientX.1") oSMTP.SendEmail "[email protected]", "[email protected]", "My Subject", "My Text...", "myserver.domain.com"
Please refer to the test HTML file for a full VBSsript example :
TestSimpleEmailClient/TestSimpleEmailClient.htmIMPLEMENTATION
==============This component relies on two MFC-related C++ class:
* CSimpleSocket: an extension of MFC class CSocket providing text and timer features
* CSimpleSMTPClient: a C++ class implementing a SMTP client.You can integrate these classes in your application if you don't want to use the component.If the COMponent "Emmanuel.SimpleDNSClient" is installed on your machine, it will be used
to find the name of you SMTP server(s) as registered in the DNS. You will not need to provide
a SMTP name as the 5th parameter of method SendEmail (just put an empty string). Please refer
to the SimpleDNSClient documentation (www.kartmann.com/emmanuel) for details.
TO DO LIST
========== * Support attachments
* Support binary data (MIME encoding)
* Support additional SMTP headers (Reply-To, Cc, Bcc, etc...)
* Support ESMTP
using MAPI!
However there are some share classes on internet that you could use !
You could download it ,and analyse it ,then to use it .You had better make sure
you understand the code before you use it !
I have one which is displayed below.However I couldn't give it to here!========================================================================
ATL COM Object : SimpleEmailClientX 1.3
========================================================================Author: Emmanuel KARTMANN <[email protected]>
Creation Date: November 28th, 1998
Last Modification Date: February 8th, 2000OVERVIEW
========This ATL COM component provides very simple Internet email functionality (SMTP).FEATURES
======== * implement the basics of SMTP, as defined in RFC821 and RFC822
* send plain text email: no attachements, no MIME encoding.
* support multiple recipients (separate email addresses with commas ',')
* support multiple email servers (try next server if email cannot be delivered to a server)
NEW * provides automatic detection of SMTP server (resolve MX record in the DNS, using COMponent SimpleDNSResolver)
* provide extended error information (ISupportErrorInfo and IErrorInfo are implemented)
* provide very small executable: 44 Ko (MinSize) to 144 Ko (MinDependency)
* require no Graphical User Interface: the component can be used in non-GUI applications,
like a Windows NT Service.
* run on Windows NT 4.0, Windows 95 and Windows 98
* compile with VC++ 6.0 SP3USAGE
=====To use this component:
* create an instance of the component,
* call method SendEmail from interface ISimpleEmailClientX,
* handle errors (try/catch in C++)SAMPLE CODE (VC++)
================== // Import smart pointer definition
#import "SimpleEmailClient.dll" no_namespace // Create smart pointer object
ISimpleEmailClientXPtr pSimpleEmailClientX; // =======================================================================
// Initialize COM (This should be called at thread startup)
// =======================================================================
HRESULT hResult = CoInitialize(NULL);
if (FAILED(hResult)) {
ErrorDialogBox("Cannot initialize COM: \n", hResult);
return; // Failed
}
// =======================================================================
// Create instance of the component to test
// =======================================================================
try
{
HRESULT hResult = S_OK;
// Create object
hResult = pSimpleEmailClientX.CreateInstance("Emmanuel.SimpleEmailClientX.1");
if (FAILED(hResult)) {
ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", hResult);
}
}
catch (_com_error &e)
{
ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", e);
} // =======================================================================
// Call method of component
// =======================================================================
try
{
HRESULT hResult = S_OK;
hResult = pSimpleEmailClientX->SendEmail(_bstr_t(m_szFrom), _bstr_t(m_szTo), _bstr_t(m_szSubject), _bstr_t(m_szBody), _bstr_t(m_szServerName));
if (FAILED(hResult)) {
ErrorDialogBox("Failure while executing method SendMail: \n", hResult);
}
}
catch (_com_error &e)
{
ErrorDialogBox("Failure while executing method SendMail: \n", e);
} // =======================================================================
// UnInitialize COM (This should be called at thread exit)
// =======================================================================
CoUninitialize();
Please refer to the test project in subdirectory "TestSimpleEmailClient" for a full example.SAMPLE CODE (VBScript)
====================== Dim oSMTP Set oSMTP = CreateObject("Emmanuel.SimpleEmailClientX.1") oSMTP.SendEmail "[email protected]", "[email protected]", "My Subject", "My Text...", "myserver.domain.com"
Please refer to the test HTML file for a full VBSsript example :
TestSimpleEmailClient/TestSimpleEmailClient.htmIMPLEMENTATION
==============This component relies on two MFC-related C++ class:
* CSimpleSocket: an extension of MFC class CSocket providing text and timer features
* CSimpleSMTPClient: a C++ class implementing a SMTP client.You can integrate these classes in your application if you don't want to use the component.If the COMponent "Emmanuel.SimpleDNSClient" is installed on your machine, it will be used
to find the name of you SMTP server(s) as registered in the DNS. You will not need to provide
a SMTP name as the 5th parameter of method SendEmail (just put an empty string). Please refer
to the SimpleDNSClient documentation (www.kartmann.com/emmanuel) for details.
TO DO LIST
========== * Support attachments
* Support binary data (MIME encoding)
* Support additional SMTP headers (Reply-To, Cc, Bcc, etc...)
* Support ESMTP
解决方案 »
- Win32的资源为什么要像下面这么写呢,是什么意思呢,是自己定义的还是VS自动生成的呢?
- 对文件的读取问题
- 关于SIP 如何组播!
- 区分非托管代码托管代码
- 主线程在规定的时刻 检查 从线程的回馈信息,根据回馈信息 决定是否终止从线程。怎么实现?谢谢!
- 我是vc新手,请高手指点下
- 交软件开发方面的朋友、本人QQ:352987119 祝:大家工作愉快!
- 关于TTS,网上几个例子都是用speech sdk,朗读英文单词的
- 怎么样隐藏鼠标
- ###############求救!为什么WIN2000 SERVER的注册表这么怪,与WIN2000 PROFESSIONAL不一样,$$$$$UP有分
- 请教微软专家阿。很急
- 用ADO打开ACCESS数据库时指定路径时出错,不指定时则正确!请高手解答
能给我一份吗?
我真的很急需。无论是VC或DELPHI都行。
多谢了
麻烦 prog_st老兄再发一份 [email protected]
双倍分
最好是VC的,多谢!!!
[email protected]
[email protected]
谢谢!