基于PFC中的of_parsetoarray()功能
pfc的n_cst_string中有相关的函数:
of_arraytostring() 将数组做成字符串
of_getkeyvalue() 得到字符串中的keyvalue
of_parsetoarray() 将字符串分解为数组
string ls_address,ls_temp,ls_error,ls_arraystring[]
integer li_returnarray,i,li_rc
mailsession msin
mailreturncode m_rtc
mailmessage m_message
mailfiledescription mattach
n_cst_string lnv_string
//创建邮件会话的实例
msin=create mailsession
m_rtc=msin.maillogon(mailnewsession!)
if m_rtc<>mailreturnsuccess! then return 1
//创建邮件会话主体
m_message.subject=sle_title.text
m_message.notetext=mle_content.text
//判断邮件地址的有效性
if string(sle_address.text)<>"" then
ls_address=sle_address.text
ls_temp=lnv_string.of_globalreplace(ls_address, ',', ';')
li_returnarray=lnv_string.of_parsetoarray(ls_temp,';',ls_arraystring)
if li_returnarray>0 then
for i=1 to li_returnarray step 1
m_message.recipient[i].address=trim(ls_arraystring[i])
next
end if
else
m_message.recipient[1].address=';'
end if
/*发送多个邮件附件*/
if mle_attachment.text<>"" then
ls_temp=lnv_string.of_globalreplace(mle_attachment.text, ',', ';')
li_returnarray=lnv_string.of_parsetoarray(ls_temp,';',ls_arraystring)
if li_returnarray>0 then
for i=1 to li_returnarray step 1
mattach.filetype=mailattach!
mattach.pathname=trim(ls_arraystring[i])
mattach.position=len(m_message.notetext)-1
m_message.attachmentfile[i]=mattach
next
end if
end if
/*选择地址进行发送*/
/*发送邮件*/
m_rtc=msin.mailsend(m_message)
if m_rtc=mailreturnsuccess! then
ib_disableclosequery=true
li_rc=1
else
ls_error=of_geterror(m_rtc)
li_rc=-1
end if
msin.maillogoff()
destroy msin
if ls_error<>"" then messagebox("错误!",ls_error)
return li_rc