如何用程序从outlook express中提取出邮件,然后将邮件批量发出

xiao234666 2008-03-01 03:39:00
以前在类似的帖子里看见过如何提取的解答,我得到一段代码,但我运行时提示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",向邮件服务器发出该邮件
...全文
206 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ydlchina 2008-03-01
  • 打赏
  • 举报
回复
outlook 和Express是连个东西,express的操作记得应该使用一个DLL,你可以到网上查查
xiao234666 2008-03-01
  • 打赏
  • 举报
回复
我安装的是outlook express
那么在调用CreateOleObject("Outlook.Application");时,我该怎么写里面的参数呢?希望得到指点
ydlchina 2008-03-01
  • 打赏
  • 举报
回复
我只是解决你的错误,使用正确的头文件。至于你的代码是否有误,没有试。没有安装outlook
xiao234666 2008-03-01
  • 打赏
  • 举报
回复
我刚刚试了,如果使用#include "Comobj.hpp"
去掉#include "oleauto.hpp"
虽然编译能通过,但调试时只要遇到CreateOleObject就出错
ydlchina 2008-03-01
  • 打赏
  • 举报
回复
使用#include "Comobj.hpp"
去掉#include "oleauto.hpp"
xiao234666 2008-03-01
  • 打赏
  • 举报
回复
我的头文件只有两个:
#include "vcl.h"

//#pragma hdrstop
//#include <iostream.h>
#include "oleauto.hpp"
//#include "oleauto.h"
//#include <math.h>
//using namespace ComObj

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");
}
ydlchina 2008-03-01
  • 打赏
  • 举报
回复
问题1 不是少了头文件,而是多了,猜想你可能包含 comobj.hpp有包含oleauto.h

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧