关于邮件的问题,请教各位大神,谢谢!
1、发邮件,我已经通过cdo实现了发邮件,但是有一个问题,就是我想把.rtf格式的内容以邮件正文的方式发出去,结果收到的是一大板乱码,请问是怎么回事?
ssl = 1
TRY
lcErr = ""
lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
loConfig =Createobject("CDO.Configuration")
With loConfig.Fields
.Item(lcSchema + "smtpserver") = 'mail.gtjas.com'
.Item(lcSchema + "sendusing") = 2
.Item(lcSchema + "smtpauthenticate") = .T.
IF ssl = 1 &&
.Item(lcSchema + "smtpserverport") = 465 &&
.Item(lcSchema + "smtpusessl") = .T.
ELSE
.Item(lcSchema + "smtpserverport") = 25
.Item(lcSchema + "smtpusessl") = .f.
Endif
.Item(lcSchema + "sendusername") = 'chunguanghui@gtjas.com'
.Item(lcSchema + "sendpassword") = 'chunghl511211'
.Item("urn:schemas:mailheader:disposition-notification-to") = mail_from &&设置“已读”回执
.Item("urn:schemas:mailheader:return-receipt-to") = mail_from && 设置“已送达”回执
.Update
Endwith
loMsg =Createobject ("CDO.Message")
IF !EMPTY(cFile)
loMsg.AddAttachment(cFile)
ENDIF
WITH loMsg
.Configuration = loConfig
.From = mail_from
.To = mail_to
.Subject = ALLTRIM(&wjmc151 .name)+'&ylj'+'工资单' &&主题
.htmlBody = FILETOSTR('&cFile1') &&正文 '&cFile1'是一个.rtf格式的文件,发给别人后,这个正文就全是乱码
.Send()
Endwith
Catch TO loError
2、我需要以IMAP--SSL方式来收邮件,我在网上找了半天也没有找到相关的内容,请各位大神帮忙推荐一些这方面的内容和思路,谢谢!我已经脑袋都想破了,也无从下手!!
[解决办法]
关于收邮件,你可以用木瓜的MyFll.fll中的Pop3GetMail()函数等或
用VFP 5.0的MAPI控件收发邮件。
1. 插入MAPI控件的方法:
在VFP 5.0主菜单的“工具”项中选择“选项”,在弹出的控件栏中,双击“Microsoft MAPI Control 5.0”项,那么,在窗体工具箱中就有了上述控件。
2.建立含有如下控件的窗体:
控件 NAME CAPTION
窗体 frmMail 用VFP 5.0的MAPI控件收发邮件
MAPISession控件 MailSess
MAPIMessage控件 MailMess
命令按钮 command1 发件箱
命令按钮 command2 收件箱
命令按钮 command3 退出
输入“发件箱”按钮单击事件的程序代码:
thisform.MailSess.SignOn
thisform.MailMess.SessionID = thisform.MailSess.SessionID
thisform.MailMess.MsgIndex = -1
thisform.MailMess.RecipDisplayName = "zjport@public.jsinfo.com.cn"
thisform.MailMess.MsgSubject = "信件"
thisform.MailMess.MsgNoteText = "请给我发邮件!"
thisform.MailMess.Send (.F.)
thisform.MailSess.SignOff
输入“收件箱”按钮单击事件的程序代码:
thisform.MailSess.SignOn
thisform.MailMess.SessionID = thisform.MailSess.SessionID
thisform.MailMess.FetchSorted = .T.
thisform.MailMess.FetchUnreadOnly = .T.
thisform.MailMess.Action = 1
xx=''
for mm=0 to thisform.MailMess.MsgCount-1
thisform.MailMess.MsgIndex = mm
xx=xx+thisform.MailMess.MsgNoteText+chr(13)+chr(10)
endf
thisform.MailSess.SignOff
输入“退出”按钮的程序代码:
thisform.MailSess.SignOff
release thisform