CDONTS to send emails
Hello,
I am having problem using CDONTS to send email through VB 6.0 App on WinXp machine. The problem I am having is that, when I use CDONTS in App, the App shows as if it generates the email. But email is not triggered until I log off from the Windows.
The email comes to Inbox, only when I log off from Windows. Seems the email is not flushed and remains in some queue.
Has anybody encountered similar problem? Any suggestion/solution to this problem is appreciated.
Thanks,
Hardik
[524 byte] By [
hardik] at [2007-11-20 11:53:42]

# 2 Re: CDONTS to send emails
Yes, I am setting the mail object to Nothing. Here is the code:
===============================================
Public gsEmailTo As String
Public gsEmailCC As String
Public gsEmailBCC As String
Public gsEmailFrom As String
Public gsEmailSubject As String
Public Sub SendEmail(ByVal vsSubject, ByVal vsEmailBody As String)
On Error GoTo Errorhandle
Dim oEmail As Object
Dim sSubject As String
Dim sFilename As String
If gsEmailTo = "" And gsEmailCC = "" And gsEmailBCC = "" Then
Exit Sub
End If
If gsEmailSubject <> "" Then
sSubject = gsEmailSubject & ": " & vsSubject
Else
sSubject = vsSubject
End If
Set oEmail = CreateObject("CDONTS.NewMail")
If gsEmailFrom <> "" Then
oEmail.From = gsEmailFrom
Else
oEmail.From = App.EXEName
End If
If gsEmailTo <> "" Then oEmail.To = gsEmailTo
If gsEmailCC <> "" Then oEmail.CC = gsEmailCC
If gsEmailBCC <> "" Then oEmail.Bcc = gsEmailBCC
oEmail.Subject = sSubject
oEmail.Body = vsEmailBody
oEmail.Importance = giEmailImportance
oEmail.Send
Set oEmail = Nothing
Exit Sub
Errorhandle:
' Some error handling...
Exit Sub
End Sub
Private Sub Calling_Function()
gsEmailFrom = "abc@xyz.com"
gsEmailTo = "abc@xyz.com"
SendEmail "This is Subject", "This is email Body"
End Sub
===============================================
hardik at 2007-11-9 19:33:10 >

# 4 Re: CDONTS to send emails
It seems I haven't got CDONTS on my system, so I cannot try out your code.
A suggestion: do NOT set oEMail = Nothing immediately.
I don't know this object, but maybe there is some status property you can read to determine whether the mail has been send or sending is still inprogress? So as you could wait with destruction of email object until the mail was successfully sent.
It's just a blind shot...
WoF at 2007-11-9 19:35:09 >
