用indy收邮件的问题,怎么样把邮件存放到本地,最好是存到数据库
http://www.delphi2007.net/DelphiNetwork/html/delphi_20061215094636123.html
现在用indy收邮件,邮件是可以收了,但是不知道怎么样最好的保存方法,也不知道foxmail怎么保存的,也 不知道怎么样把他保存到数据库中,感觉他的数据库类型比较麻烦,附件的话是不是一般都不存到数据库中的?
请高手指教
可以实现的 等等写个列子给你看~~
//****************************收取指定的邮件************************************
function Trec_mail.Get_Receive(lett_index: OleVariant): OleVariant;
var
nmm_strUidl,nmm_strAttachFileName:string;
nmm_strDirName,nmm_strUrlPath:string;
nmm_strAttachFileUrl,nmm_strAttachFilePath:widestring;
nmm_index:integer;
nmm_strbody:widestring;
nmm_strdecode:string;
begin
try
nmg_intLetterIndex :=strtoint(lett_index); //全局变量邮件id
nmm_strUidl := trim(get_uid);
nmg_msgBody.clear;
nmg_msgBody.NoDecode := false;
nmg_msgBody.IsEncoded := true;
try
nmg_pop.Retrieve(nmg_intLetterindex,nmg_msgBody);
except
result:='';
exit;
end;
nmg_msgHead.clear;
nmg_msgHead.NoDecode := false;
nmg_msgHead.IsEncoded := true;
try
nmg_pop.RetrieveHeader(nmg_intLetterIndex,nmg_msgHead);
except
result:='';
exit;
end;
if nmg_strMailUserDir='' then
begin
nmm_strDirName := nmg_strRootDir+nmm_strUidl;
nmm_strUrlPath := nmg_strRootUrlPath+nmm_strUidl;
end
else
begin
nmm_strDirName := nmg_strRootDir+nmg_strMailUserDir+'\'+nmm_strUidl;
nmm_strUrlPath := nmg_strRootUrlPath+nmg_strMailUserDir+'/'+nmm_strUidl;
end;
ForceDirectories(nmm_strDirName);
FormAttachHtm;
nmg_blnHasAttOut := false;
//*************************正文的下载***************************************
try
if nmg_msgBody.messageparts.Count=0 then nmg_stsContent :=nmg_msgBody.Body
else begin
for nmm_index:=0 to pred(nmg_msgBody.messageparts.Count) do
if nmg_msgBody.MessageParts.Items[nmm_index] is TIdText then nmg_stsContent := TIdText(nmg_msgBody.MessageParts.Items[nmm_index]).Body;
end;
except
result:='';
exit;
end;
if (pos('HTML>',nmg_stsContent.text))or(pos('html>',nmg_stsContent.text))<1 then nmg_stsContent.text:='<pre>'+nmg_stsContent.text+'</pre>';
//*************************附件的下载***************************************
for nmm_index:=0 to pred(nmg_msgBody.messageparts.Count) do
begin
if (nmg_msgBody.MessageParts.Items[nmm_index] is TIdAttachment) then
begin
nmm_strAttachFileName :=DecodeHeader(TIdAttachment(nmg_msgBody.MessageParts.Items[nmm_index]).Filename);
nmm_strAttachFileUrl := nmm_strUrlPath;
nmm_strdecode:=(tidattachment(nmg_msgBody.MessageParts.Items[nmm_index]).ContentDisposition);
if trim(nmm_strdecode)<>'' then
begin
nmm_strAttachFilePath := nmm_strDirName + '\attachment\'+inttostr(nmm_index);
ForceDirectories(nmm_strAttachFilePath);
nmm_strAttachFileUrl := nmm_strAttachFileUrl+'/attachment/'+inttostr(nmm_index)+'/'+nmm_strAttachFileName;
nmm_strAttachFilePath := nmm_strAttachFilePath+'\'+nmm_strAttachFileName;
try
if not fileexists(nmm_strAttachFilePath) then
tidattachment(nmg_msgBody.MessageParts.Items[nmm_index]).SaveToFile(nmm_strAttachFilePath);
except
continue;
end;
nmg_stsAttach.add('<a href="'+ nmm_strAttachFileUrl+'" target=_blank> '+nmm_strAttachFileName+'</a><BR><br>');
nmg_blnHasAttOut := true ;
end
else
begin
nmm_strAttachFilePath := nmm_strDirName+'\Image\'+inttostr(nmm_index);
nmm_strAttachFileUrl := nmm_strAttachFileUrl+'\Image\'+inttostr(nmm_index)+'\'+nmm_strAttachFileName;
ForceDirectories(nmm_strAttachFilePath);
nmm_strAttachFilePath := nmm_strAttachFilePath+'\'+nmm_strAttachFileName;
try
if not fileexists(nmm_strAttachFilePath) then
tidattachment(nmg_msgBody.MessageParts.Items[nmm_index]).SaveToFile(nmm_strAttachFilePath);
except
continue;
end;
//*************************替换图片src****************
nmg_Reg.Expression :='src\s*=\s*"?[^\s]*@[^\s]*"?';
nmm_strbody :=nmg_stsContent.text;
if nmg_reg.Exec(nmm_strbody) then
begin
nmm_strbody:=StringReplace(nmm_strbody,nmg_reg.Match[0],
'src='+nmm_strAttachFileUrl,[rfReplaceAll, rfIgnoreCase]);
nmg_stsContent.Text := nmm_strbody;
end;
//****************************************************
end;
end;
end;
if nmg_blnHasAttOut =true then FinishAttachHtm(nmm_strDirName+'\mailatt.htm');
FinishContentHtm(nmm_strDirName+'\mailcont.htm');
//******************************收取完成************************************
nmg_reRunTimeErr:=reSuccess;
nmg_arrAllErrString[Ord(reGetReceiveErr)] := '收取指定邮件成功.';
except
ON E:Exception do
begin
Result := '';
nmg_reRunTimeErr:=reGetReceiveErr;
nmg_arrAllErrString[Ord(nmg_reRunTimeErr)] := E.Message;
end;
end;
Result := nmg_reRunTimeErr;
end;
多谢高手,我先研究一下,稍后给分
to:zuoansuifeng,你代码中的以下几个函数的代码能再给一下啊。
FormAttachHtm,DecodeHeader,FinishAttachHtm,FinishContentHtm,nmg_stsAttach
先谢了
zuoansuifeng好人
我自己已经搞定了
不过还是谢谢 zuoansuifeng(左岸)
散分结贴了
转载于:https://www.cnblogs.com/delphi2007/archive/2008/10/28/1321002.html
用indy收邮件的问题,怎么样把邮件存放到本地,最好是存到数据库相关推荐
- java 拉取收件箱邮件源码_邮件提醒系统:新邮件识别
最近在做邮件提醒抄送企业微信消息系统,就目前而言,无论是pop3还是imap都没有一个好的方法只接收新邮件,基本只能依靠收件箱列表message自行判断,下面给出几种思路并作对比. //收件箱 fol ...
- 邮政收件箱界面html,时尚邮件收件箱UI设计效果
这是一款效果非常现代时尚的邮件收件箱UI设计.该邮件收件箱UI设计以简洁的列表方式列出所有的邮件,用户点击相应的邮件时会以动画的方式弹出该邮件的详细信息. 使用方法 HTML结构 在这个邮件收件箱UI ...
- 邮箱收不到邮件怎么办,跨国的邮件为什么收不到?
邮箱收不到邮件怎么办,跨国的邮件为什么收不到?电子邮箱使用过程中,常会遇到收不到对方发来的邮件的情况,遇到此类情况先不要着急,分享几招快速自查及解决的方法,网络辛苦搜集的,快操作起来吧~ 收不到邮件原 ...
- ipad邮件qq收件服务器,iPad自带邮件功能收发邮件的过程
1.进入Mail:在主菜单中找到Mail图标,用手指轻触图标便可以轻松进入iPad的邮件客户端. 2.设置Mail:在弹出的窗口中选择邮件服务商.如果当前没有对应网易邮箱,则选择屏幕中的"其 ...
- 格拉斯哥邮箱收件服务器,橄榄邮SSL邮件客户端设置帮助
为满足客户需求,橄榄邮正式推出了SSL邮件收取和发送功能,目前仅提供给橄榄邮付费用户使用,设置方法如下: ● office OUTLOOK 2007版本设置 1.点击[windows开始菜单]-- 搜 ...
- thunderbird收件箱只显示邮件个数,无法打开邮件
周一来上班的时候,thunderbird邮件打开,只能看到邮件个数,具体邮件右侧显示空白.当时没怎么留意,以为是邮箱满了或者公司邮件服务器升级之类的,就改用web版,但是web版邮件用的时候,正文里面 ...
- java mail 收 附件_使用 JavaMail 收发邮件,解决中文附件问题
几天来一直在开发一个项目,其中一部分需要用 JavaMail 收发邮件,于是就在网上找了一些相关的源代码,最后经过整理和修改,终于好使了,希望能够给使用 JavaMail 收发邮件的朋友提供一个参考 ...
- 邮件服务器收件人数量限制,邮件服务器DBMail
错误原因:因为收件人邮箱帐号不存在或者收件方邮件服务器无法找到收件人邮件地址,所以对方服务器不接收此封邮件. 可能出现的关键字:No such user.user unknown.unknown or ...
- 企业邮箱服务器删除邮件,企业邮箱Webmail对邮件进行删除或者清空邮件的方法...
问题场景: 使用万网企业邮箱webmail时,如对现有邮件需要删除,可参考以下不同删除邮件方法. 注意事项: - 删除 操作后,邮件会自动放入 已删除 文件夹. 彻底删除 操作时,邮件将从邮箱内彻底删 ...
- linux命令查询邮件发送状态,Linux发邮件之mail命令详解
一.mail命令 1.配置 vim /etc/mail.rc 文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com" set ...
最新文章
- Android源码下载(ubuntu12.04(amd64))
- 函数式编程之-模式匹配(Pattern matching)
- quartz获取开始结束时间_Springboot集成quartz
- 74款android开机动画,修改Android系统开机动画
- 计算机博士专业目录,tsinghua计算机博士专业目录
- Spring框架学习——AOP
- [论文解读]NBDT: Neural-Backed Decision Trees
- 【2016.5.27】再见,软件工程,你好,软件工程。
- 【备忘】hive 调优
- 用Go建千亿级微服务 分析详细,适合新手理解概念
- android 通知栏设置,安卓手机通知栏介绍:安卓手机通知栏设置方法
- 首涂[A020]第二十套模板最终版 苹果CMS V10
- 招商大师与星范集团等医美龙头达成战略合作 从提业绩到建标杆
- 华为研究院19级研究员几年心得终成趣谈网络协议文档,附讲解
- 【小程序】滚动到指定位置
- Docker容器离线安装字体(宋体)
- 【微信小程序】把客服按钮替换成自己想要的图片
- 《黑镜》第一季观后感
- 河南省中专高考计算机大专分数线,河南省中专分数线一般多少分
- “一见杨过误终身” ——体验式营销,你也可以创造传奇_营销人论坛
热门文章
- eclipse SVN插件的缓存清理
- windows server 2000系统安装
- IOS版aplayer使用教程_管家婆服装版使用教程,重庆任我行管家婆服装软件的使用方法...
- mysql msdtc 不支持_MSDTC”该伙伴事务管理器已经禁止了它对远程网络事务的支持”的错误(转) | 学步园...
- 成功破解电信限制路由器方法
- 淘宝的安全登录怎么做的
- 如何查询目标计算机的ip地址,基于Wireshark获取目标ip地址
- EditPlus编码格式设置
- Android Canvas.DrawLine绘制线段
- VideoEdit+ User Manual