B
bhipwell via AccessMonster.com
This has been driving me nuts. I am receiving an "Object variable or With
block variable" error on this code. It seems if I reload the code, it will
work. Any touching of it, however, smacks me with the error. Here is the
entire code on the form. Please help! Also, I need a way of simply
attaching a file located in my C drive, any help on this would be a bonus.
Option Compare Database
Dim WithEvents oSMTP As OSSMTP.SMTPSession
Private Sub cmdSend_Click()
txtStatus = ""
With oSMTP
'connection
'ERROR POPS UP HERE!
.Server = txtServer
'message
.MailFrom = txtMailFrom
.SendTo = txtSendTo
.MessageSubject = txtMessageSubject
.MessageText = txtMessageText
'send email
txtStatus.SetFocus
.SendEmail
End With
End Sub
Private Sub Form_Load()
Set oSMTP = New OSSMTP.SMTPSession
txtServer = "localhost"
txtMailFrom = "info"
txtSendTo = "test"
txtMessageSubject = "test"
txtMessageText = "some text"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set oSMTP = Nothing
End Sub
Private Sub oSMTP_ErrorSMTP(ByVal Number As Integer, Description As String)
txtStatus = txtStatus & "Error " & Number & ": " & Description & vbCrLf
txtStatus.SelStart = Len(txtStatus)
End Sub
Private Sub oSMTP_StatusChanged(ByVal Status As String)
txtStatus = txtStatus & oSMTP.Status & vbCrLf
txtStatus.SelStart = Len(txtStatus)
End Sub
B
block variable" error on this code. It seems if I reload the code, it will
work. Any touching of it, however, smacks me with the error. Here is the
entire code on the form. Please help! Also, I need a way of simply
attaching a file located in my C drive, any help on this would be a bonus.
Option Compare Database
Dim WithEvents oSMTP As OSSMTP.SMTPSession
Private Sub cmdSend_Click()
txtStatus = ""
With oSMTP
'connection
'ERROR POPS UP HERE!
.Server = txtServer
'message
.MailFrom = txtMailFrom
.SendTo = txtSendTo
.MessageSubject = txtMessageSubject
.MessageText = txtMessageText
'send email
txtStatus.SetFocus
.SendEmail
End With
End Sub
Private Sub Form_Load()
Set oSMTP = New OSSMTP.SMTPSession
txtServer = "localhost"
txtMailFrom = "info"
txtSendTo = "test"
txtMessageSubject = "test"
txtMessageText = "some text"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set oSMTP = Nothing
End Sub
Private Sub oSMTP_ErrorSMTP(ByVal Number As Integer, Description As String)
txtStatus = txtStatus & "Error " & Number & ": " & Description & vbCrLf
txtStatus.SelStart = Len(txtStatus)
End Sub
Private Sub oSMTP_StatusChanged(ByVal Status As String)
txtStatus = txtStatus & oSMTP.Status & vbCrLf
txtStatus.SelStart = Len(txtStatus)
End Sub
B