用JMail傳送郵件

2021-09-30 02:59:02 字數 1737 閱讀 2312

function sendmail(byval from as string, _

byval recipient as string, _

byval recipientcc as string, _

byval recipientbcc as string, _

byval subject as string, _

byval body as string, _

byval attachment as string, _

byval priority as integer, _

byval mailserver as string, _

byval mailserverusername as string, _

byval mailserverpassword as string) as boolean

'from                 傳送位址

'recipient            接收位址

'recipientcc          副本抄送

'recipientbcc         隱藏的副本抄送

'subject              郵件標題

'body                 郵件內容

'attachment           附件

'priority             郵件的優先程度,從1到5

'mailserver           smtp伺服器的ip位址或名稱

'mailserverusername   smtp伺服器使用者名稱

'mailserverpassword   smtp伺服器密碼

dim email as new jmail.message

with email

.logging = true '呼叫log記錄,供debug用

.silent = true

.mailserverusername = mailserverusername  'smtp伺服器使用者名稱

.mailserverpassword = mailserverpassword  'smtp伺服器密碼

.from = from                                  '傳送位址

.addrecipient (recipient)                 '接收位址

.addrecipientbcc (recipientbcc)           '隱藏的副本抄送

.addrecipientcc (recipientcc)                '副本抄送

.subject = subject                        '郵件標題

.body = body                               '郵件內容

if len(attachment) > 0 then .addattachment (attachment) '附件

.priority = priority

if email.send(mailserver) then            '傳送到smtp伺服器

sendmail = true

else

sendmail = false

end if

end with

doevents

set email = nothing    '銷毀例項

end function

JMail傳送郵件元件用法

先看乙個簡單的例子 jmail4.3 應用事例 4.3 以前引數差不多 建立傳送郵件的物件 jmail4.0 server.createobject jmail.tpmail set jmail server.createobject jmail.message jmail.silent true ...

c 利用jmail傳送郵件

測試環境 win2003 1.確認你的機器或伺服器安裝了smtp伺服器,如果沒有安裝請到新增刪除程式裡面的新增刪除元件中新增電子郵件服務。2.安裝jmail4.3 3.找到jmail.dll 安裝目錄下 4.執行program files microsoft visual studio net fr...

Jmail傳送和接收郵件

一 利用jmail傳送郵件 1 2 利用jmail傳送郵件 3 4private void sendmailbyjmail 545 46 郵件內容 47 ojmailmessage.body txtcontent.text.trim 4849 if ojmailmessage.send txtsmt...