如何用程序从outlook express中取出邮件
以前在类似的帖子里看见过如何提取的解答,我得到一段代码,经过我加上头文件整理后得:
#include "vcl.h"
#include "oleauto.hpp"
void main()
{
Variant vOutlook, vNameSpace;
Variant vFolder, vMsg;
int nMailCounter;
try
{
vOutlook = CreateOleObject("Outlook.Application");
}
catch(...)
{
ShowMessage("error in create ole object");
}
vNameSpace = vOutlook.OleFunction("GetNameSpace", "MAPI");
// FolderTypeEnum (olFolderInbox)
vFolder = vNameSpace.OleFunction("GetDefaultFolder", 6);
nMailCounter = 1;
// If there is any email in the Inbox
if(vFolder.OlePropertyGet("Items").OlePropertyGet("Count") > 0)
{
do
{
// Get the first Email
vMsg = vFolder.OleFunction("Items", nMailCounter);
String FileName = vMsg.OlePropertyGet("Subject");
String DesPath = "C:\\"+FileName+".msg";
char* DesFilePath = DesPath.c_str();
vMsg.OleFunction("SaveAs", DesFilePath);
nMailCounter++;
}
while(nMailCounter <= vFolder.OlePropertyGet("Items").OlePropertyGet("Count"));
}
vOutlook.OleFunction("Quit");
}
但我运行时提示CreateOleObject()这个函数存在如下错误提示:
"ambiguity between '_fastcall comobj::createOleObject(const system::ansistring)' and '_fastcall oleauto::createOleObject(const system::ansistring)'"
我猜想可能缺少某个头文件,但查了下资料一直没有找到这个头文件,希望得到你或大家的解答.
还有一个问题就是:当我从outlook express中提取出了邮件后,假定得到了每封邮件的发件人,收件人,发送时间,信件内容等这些信件信息后,如何将它们再发送出去呢(发送邮件的代码希望大家能给些提示)?或许大家会有疑问,为什么得到了又要发出去呢?这是因为,我现在做一个模拟实验,需要借助outlook express这个软件方便得到大量邮件来完成我的实验.举个例子说明我到底想要干什么:
如我在outlook express中有一封发件人为"11111@163.com",收件人为"22222@126.com",发送时间为"2008年3月1日 10:00",的信件;现在我要将这封信发到我架设的一个邮件服务器上的一个邮箱,架设这个邮箱为"xxxxx@xx.com";我就将此封信件的发件人改为"邮件服务器上除用户名为xx的任意有效用户名@xx.com",收件人改为"22222@xx.com",向邮件服务器发出该邮件