文件名称:Jmail在pb中的应用
文件大小:117KB
文件格式:RAR
更新时间:2014-06-23 06:23:33
Jamil PB
/这个是一个成功的声明 FUNCTION int fsendemail(ref String sSmtpServer, ref String sSenderId, & ref String sPsw, ref String sSenderName, ref String sRcvAddr,& ref String sSenderAddr,ref String sCCAddr, & ref String sBCCAddr, ref String sSubject, & ref String sContent, ref String sAttach) Library "PSdEmail_dll.dll" 代码如下 //mail_url放邮件地址,as_mailtext放邮件内容,mail_cc是邮件的抄送地址 //as_subject是邮件主题,as_filename是附件的文件名,as_pathname是附件的完整路径名 string ls_name mailsession lms_data mailmessage lmms_message mailreturncode lmr_value integer li_i //产生邮件会话对象mses lms_data = create mailsession //邮件登录 lmr_value = lms_data.maillogon(mailnewsession!) if lmr_value <> mailreturnsuccess! then gnv_base.of_message("真不幸,邮件注册失败") return -1 end if //标题 lmms_message.subject = sle_subject.text //正文 lmms_message.notetext = trim(mle_content.text) + ' ' ////附件 //if as_pathname<> '' or as_filename<> '' then // mmsg.attachmentfile[1].pathname=as_pathname // mmsg.attachmentfile[1].filename=as_filename //end if //******************************校验收件人邮件地址是否是合法地址***************************// //原收件人 ls_name = sle_rcv.text lmr_value = lms_data.mailResolveRecipient(ls_name) if lmr_value = mailReturnSuccess! THEN lmms_message.Recipient[1].RecipientType = mailto! lmms_message.Recipient[1].address = "liuzhp@huadong.net" lmms_message.Recipient[1].name = "liuzhp@huadong.net" elseif lmr_value = mailReturnFailure! THEN gnv_base.of_message('收件人地址错误,请检查') return -1 else gnv_base.of_message('收件人地址错误,请检查') return -1 end if //发送邮件 lmr_value = lms_data.mailsend(lmms_message) if lmr_value <> mailreturnsuccess! then messagebox("邮件发送","邮件发送失败!"+char(10)+char(13)+'请检查:'+char(10)+char(13)+& '1.附件路径和名称是否正确.'+char(10)+char(13)+& '2.本地outlook配置是否正确.'+char(10)+char(13)+& '3.如以上都正确,请与系统管理员联系!') return -1 elseif lmr_value = mailreturnsuccess! then // messagebox("邮件发送","邮件发送完毕!") end if lms_data.maillogoff() //退出登录 destroy lms_data //取消邮件会话 return 1 String ls_RcvAddr //收件人 String ls_CcAddr //转发 String ls_BccAddr //暗送 String ls_Sub //主题 String ls_Content //内容 String ls_Attach = ''//附件,多个附件由ATTACHSPLIT分隔 Constant String ATTACHSPLIT = '|' //附件的分隔符号 Integer li_Rtn //返回值,0:发送成功,1:发送失败 pointer oldpointer // Declares a pointer variable oldpointer = SetPointer(HourGlass!) ls_RcvAddr = sle_Rcv.Text //收件人 ls_CcAddr = sle_CC.Text //转发 ls_BccAddr = sle_BCC.Text //暗送 ls_Sub = sle_Subject.Text //主题 ls_Content = mle_Content.Text //内容 Long ll_Row, ll_RowCnt //把附件用ATTACHSPLIT连接起来 ll_RowCnt = dw_Attach.RowCount() FOR ll_Row = 1 TO ll_RowCnt ls_Attach = ls_Attach + dw_Attach.Object.FilePath[ll_Row] +& dw_Attach.Object.FileName[ll_Row] + ATTACHSPLIT NEXT //发送 li_Rtn = fSendEmail(is_Server, is_SenderId , is_Psw, is_SenderName, is_SenderAddr,ls_RcvAddr, ls_CcAddr, ls_BccAddr, ls_Sub, ls_Content,ls_Attach) if li_rtn = 0 then gnv_base.of_message('邮件发送成功!') else gnv_base.of_message('邮件发送失败!') end if SetPointer(oldpointer) li_Rtn = fSendEmail(is_Server, is_SenderId , is_Psw, is_SenderName, is_SenderAddr, & ls_RcvAddr, ls_CcAddr
【文件预览】:
jmail.txt
jmail.dll