基於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