R
Rob Oldfield
I'm using the following to send mail from within apps....
Imports System.Web.Mail
Public Sub email(ByVal subject As String, ByVal msg As String, ByVal
whoFrom As String, _
ByVal whoTo As String, Optional ByVal attach As String = "")
'Original version taken from Q314201
Dim eMsg As MailMessage = New MailMessage
Dim eAttch As MailAttachment, str As String
Dim SMTPServer = "MyServer"
eMsg.From = whoFrom
eMsg.To = whoTo
eMsg.Subject = subject
eMsg.Body = msg
If attach <> "" Then
Dim eFile As String = attach
eAttch = New MailAttachment(eFile, MailEncoding.Base64)
eMsg.Attachments.Add(eAttch)
End If
SmtpMail.SmtpServer = SMTPServer
Try
SmtpMail.Send(eMsg)
Catch ex As Exception
str = "The attempt to send an email has failed." + vbCrLf +
vbCrLf + ex.Message
MessageBox.Show(str, "Error sending mail", MessageBoxButtons.OK)
End Try
eMsg = Nothing
eAttch = Nothing
End Sub
And that normally works. On some machines I'm getting the error "Could not
access 'CDO.Message' object." and on workstations I've got around that by
running Office update over the machines. It then works fine.
But I'm now getting the same error on a server. I run Office update and, of
course, it says there's nothing to do as Office isn't installed. So what do
I need to update?
Imports System.Web.Mail
Public Sub email(ByVal subject As String, ByVal msg As String, ByVal
whoFrom As String, _
ByVal whoTo As String, Optional ByVal attach As String = "")
'Original version taken from Q314201
Dim eMsg As MailMessage = New MailMessage
Dim eAttch As MailAttachment, str As String
Dim SMTPServer = "MyServer"
eMsg.From = whoFrom
eMsg.To = whoTo
eMsg.Subject = subject
eMsg.Body = msg
If attach <> "" Then
Dim eFile As String = attach
eAttch = New MailAttachment(eFile, MailEncoding.Base64)
eMsg.Attachments.Add(eAttch)
End If
SmtpMail.SmtpServer = SMTPServer
Try
SmtpMail.Send(eMsg)
Catch ex As Exception
str = "The attempt to send an email has failed." + vbCrLf +
vbCrLf + ex.Message
MessageBox.Show(str, "Error sending mail", MessageBoxButtons.OK)
End Try
eMsg = Nothing
eAttch = Nothing
End Sub
And that normally works. On some machines I'm getting the error "Could not
access 'CDO.Message' object." and on workstations I've got around that by
running Office update over the machines. It then works fine.
But I'm now getting the same error on a server. I run Office update and, of
course, it says there's nothing to do as Office isn't installed. So what do
I need to update?