jatfill
Registered User.
- Local time
- Today, 04:49
- Joined
- Jun 4, 2001
- Messages
- 150
I may have finally found a solution for those of us who would very much like to circumvent Outlook's nasty little problem with VBA-induced emailing.
I
found an activex control at this site...
http://axsoft.hypermart.net/
it's called "axSMTP" & it's basically an SMTP control intended for Visual Basic, but I do SORT OF have it working in VBA.
My intention is to use this in conjunction with PostCast's SMTP server, which will run on any desktop in a fairly transparent manner, and avoid using MAPI altogether.
So I have registered the OCX file & placed the control on a form, "frmEmail", & this is what I have for the code behind the form:
it does what it's supposed to, except the "SMTP_MailSendComplete" event never fires, and the message doesn't show up on the server queue until you manually disconnect from the form (see the cmdSend_Click procedure)?
I was hoping to post this here a.) so that others could see the option and b.) someone might be able to help me tweak this and actually get it running... any ideas would be greatly appreciated
I
found an activex control at this site...
http://axsoft.hypermart.net/
it's called "axSMTP" & it's basically an SMTP control intended for Visual Basic, but I do SORT OF have it working in VBA.
My intention is to use this in conjunction with PostCast's SMTP server, which will run on any desktop in a fairly transparent manner, and avoid using MAPI altogether.
So I have registered the OCX file & placed the control on a form, "frmEmail", & this is what I have for the code behind the form:
Code:
Option Compare Database
Option Explicit
Dim thisDb As Database
Dim recSet As Recordset
Private Sub cmdSend_Click()
If cmdSend.Caption = "&Send" Then
cmdSend.Caption = "&Stop"
' Open the database
Set thisDb = currentDb
Set recSet = thisDb.OpenRecordset("tblEmail")
lblStatus.Caption = "Connecting ... "
' Set the SMTP options and connect
SMTP.Server = Me.txtServer
SMTP.SenderEmailAddress = Me.txtFromLine
SMTP.SenderName = Me.txtFromName
SMTP.Connect
Else
cmdSend.Caption = "&Send"
SMTP.Disconnect
End If
End Sub
Private Sub sendCurrentMail()
If Not recSet.EOF Then
lblStatus.Caption = "Sending mail to " & recSet!email
' Set the message and send it
SMTP.Recipients = recSet!email
SMTP.MessageSubject = Me.txtSubject
SMTP.MessageBody = Me.txtMessage
'uncomment to add attachments to message
'SMTP.Attachments = recSet!file
SMTP.SendMail
Else
' All messagess have been sent
MsgBox "Messages sent"
SMTP.Disconnect
End If
End Sub
Private Sub SMTP_Connected()
lblStatus.Caption = "Connected"
recSet.MoveFirst
sendCurrentMail
End Sub
Private Sub SMTP_MailSendComplete()
lblStatus.Caption = "Message sent"
recSet.MoveNext
sendCurrentMail
End Sub
Private Sub SMTP_Error(Number As Long, Description As String, ServerResponse As String)
MsgBox Description & ": " & ServerResponse
End Sub
Private Sub SMTP_Disconnected()
lblStatus.Caption = "Disconnected"
recSet.Close
End Sub
Private Sub SMTP_MessageProgress(MessageBytesSent As Long, TotalMessageSize As Long, CurrentAttachmentFilename As String)
lblStatus.Caption = "Sent " & MessageBytesSent & " of " & TotalMessageSize
End Sub
it does what it's supposed to, except the "SMTP_MailSendComplete" event never fires, and the message doesn't show up on the server queue until you manually disconnect from the form (see the cmdSend_Click procedure)?
I was hoping to post this here a.) so that others could see the option and b.) someone might be able to help me tweak this and actually get it running... any ideas would be greatly appreciated