kudqts 一級
註冊時間: 2002-05-08 文章: 1 來自: taiwan
|
發表於: 星期三 五月 08, 2002 6:32 pm 文章標題: |
|
|
版主先生,及各位先生好:
在此請教一個問題,為何範例(二)去呼叫範例(一)時mail正確,
但用範例(三)去呼叫範例(一)時竟無法mail,是否範例(三)ASP語法錯誤.
System: Window 2000 Server + IIS5 + ASP3.0
Language: VB6 Enterprise
Mail: Microsoft Outlook
範例(一) QUE Sample EMail.vbp + Service.cls = Email.dll
Option Explicit
Public Function Send(ByVal sSubject As String, _
ByVal sBody As String, _
ByVal sProfile As String, _
ByVal sRecipant As String) As Boolean
On Error GoTo Send_Err
Dim oSession As Object
Dim oMessage As Object
Dim oRecipant As Object
send = True '自行加入
Set oSession = CreateObject("MAPI.Session")
oSession.logon sProfile
Set oMessage = oSession.Outbox.Messages.Add
oMessage.Subject = sSubject
oMessage.Text = sBody
Set oRecipant = oMessage.Recipients.Add
oRecipant.Name = sRecipant
oRecipant.Resolve
oMessage.Update
oMessage.Send showDialog:=False
oSession.Logoff
Exit Function
Send_Err:
App.LogEvent Err.Description
Send = False '自行加入
End Function
範例(二) QUE Sample Emailtest.exe
Option Explicit
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSendEmail_Click()
On Error GoTo CreateSessionAndLogon_Err
Dim oMail As Object
Set oMail = CreateObject("EMail.Service")
oMail.Send txtSubject, txtBody, _
"Microsoft Outlook Internet Settings", _
"admin@mail.sunyder.com.tw"
MsgBox "QUE Message sent!"
Set oMail = Nothing
Exit Sub
CreateSessionAndLogon_Err:
MsgBox Err.Description
End Sub
範例(三)
<% @language="vbscript" %>
<% dim objmail, txtsubject, txtbody, txtprofile
txtsubject = "mail"
txtbody = "This Is My First Mail For Web Testing!"
txtprofile = "Microsoft Outlook Internet Settings"
set objmail = server.CreateObject("EMail.service")
if objmail.Send (txtsubject, txtbody, txtprofile, "admin@mail.sunyder.com.tw") = false then
Response.Write "mail failed" ‘會執行這一行
Else
Response.Write "mail have passed"
end if
Set objmail = Nothing
%>
|
|