開始使用Mymail.dll ,發送郵件(在timer事件寫的發送,即發現有附件即觸發發送函式) 一切正常,程式后臺運行幾周都沒問題,后來看見網上說jmail.dll 比mymail.dll好用,就講程式改用調jmail.dll后,自動執行2天 基本程式就死在那了,資源管理器發下,程式記憶體占用增長了不少,不知道什么原因 ,哪位高手給指點一下,謝謝
1、定義視窗級別 實體 OLE物件
oleobject lole-jmail
2、定義視窗open 事件creat
String ls_userid,ls_password,ls_sender
Long ll_net
lole_jmail = Create oleobject
ls_userid=uo_send_info.sle_user.text
ls_password=uo_send_info.sle_pass.text
ls_sender = uo_send_info.sle_sender.text
ll_net = lole_jmail.ConnectToNewObject("Jmail.Message")
If ll_net = 0 Then
lole_jmail.Charset="gb2312"
lole_jmail.Encoding="base64"//
lole_jmail.ContentTransferEncoding = "base64"//
lole_jmail.ISOEncodeHeaders=true
lole_jmail.silent=true
lole_jmail.Logging=true
lole_jmail.From=ls_sender
lole_jmail.FromName="有限公司"//ls_userid // 發件人姓名
lole_jmail.MailServerUserName=ls_sender
lole_jmail.MailServerPassword=ls_password // 發件郵箱用戶密碼
end if
3、在timer 事件 執行 發送函式
of_send(),該函式 5秒執行一次,程式運行2天 基本都死掉,估計問題在這里。。。
===
核心函式代碼如下:
String ls_host
String ls_ready,ls_finished,ls_isattach,ls_flag,ls_subject,ls_body,ls_origpath,ls_origfile,ls_orig
String ls_recipient,lsa_recipient[]
Long ll_cnt,i,j,k,ll_net
gb_running = True
ll_cnt = dw_send.RowCount()
If ll_cnt<=0 Then
MessageBox("系統提示","請先配置收件人地址!")
Return -1
End If
ls_host=uo_send_info.sle_host.text
If IsValid(lole_jmail) Then
For i = 1 To ll_cnt
ls_ready = Trim(dw_send.GetItemString(i,"ready"))
ls_finished = Trim(dw_send.GetItemString(i,"finished"))
ls_isattach = Trim(dw_send.GetItemString(i,"isattach"))
ls_flag = Trim(dw_send.GetItemString(i,"flag"))
ls_recipient = Trim(dw_send.GetItemString(i,"recipient"))
ls_subject = Trim(dw_send.GetItemString(i,"subject"))
ls_body = Trim(dw_send.GetItemString(i,"body"))
ls_origpath = Trim(dw_send.GetItemString(i,"origpath"))
ls_origfile = Trim(dw_send.GetItemString(i,"origfile"))
ls_orig = ls_origpath+ls_origfile
If ls_flag = 'n' Then Continue;
If as_repeat = "n" Then
If ls_finished = 'y' Then Continue;
End If
If ls_ready = 'y' Then
gf_string2array(ls_recipient,';',lsa_recipient[])
// 收件人
lole_jmail.ClearRecipients()
For j = 1 to upperbound(lsa_recipient[])
If pos(lsa_recipient[j],'@')>0 Then
lole_jmail.AddRecipient(lsa_recipient[j])
End If
Next
lole_jmail.Subject=ls_subject
lole_jmail.Priority=3 // 優先級
lole_jmail.Body=ls_body //郵件內容
// 附件
If ls_isattach = 'y' Then
For k = 1 to 1 //只有一個附件
//lole_jmail.addattachment(plb_attachment.text(i))
lole_jmail.ClearAttachments()
lole_jmail.addattachment(ls_orig)
Next
End If
If lole_jmail.Send(ls_host) Then
mle_1.text=Trim(mle_1.text)+"發送成功: ["+ls_origfile + "]: "+"~r~n"
gf_writelog("發送成功: ["+ls_origfile + "]")
If Not of_save_send_log(ls_origfile,ls_recipient) Then
mle_1.text=Trim(mle_1.text)+"保存log失敗: ["+ls_origfile + "]: "+"~r~n"
gf_writelog("保存log失敗: ["+ls_origfile + "]")
End If
Else
mle_1.text=Trim(mle_1.text)+"發送失敗: ["+ls_origfile + "]: "+"~r~n"
gf_writelog("發送失敗: ["+ls_origfile + "]")
End if
End If
Next
End If
gb_running = False
Return 1
uj5u.com熱心網友回復:
mymail.dll不知道誰寫的,如果好用,建議不要換,用Jmail的話注意物件的關閉和釋放
uj5u.com熱心網友回復:
java記憶體占用不斷增加應該是先天的問題我們機房里最不穩定,經常需要重新啟動的機器大部分都是跑java應用的
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/33024.html
標籤:API 調用
