G
Guest
Hi - I'm trying to attach a comma-delimited output file created from ACCESS
to an email message to send to a supplier. Someone at the ACCESS newsgroup
suggested the following code:
Public Sub SendMailCDO(ToWHom As String, FromWhom As String, Subject As
String, Body As String, Optional AttachmentPath As String)
Const cdoDefaults = -1
Const cdoIIS = 1
Const cdoOutlookExpress = 2
Dim Message As Object 'CDO.Message
Set Message = CreateObject("CDO.Message")
With Message
'Use dafault config from system
.Configuration.Load -1
.To = ToWHom
If Len(FromWhom) > 0 Then
.From = FromWhom
End If
.Subject = Subject
.TextBody = Body
If Len(AttachmentPath) > 0 Then
.AddAttachment AttachmentPath
End If
.Send
End With
End Sub
I get a runtime error (at the .Send, I imagine) which says that the message
could not be sent to the server.
Can you shed any light on this? A couple of possibilites that have occurred
to me are:
(1) Only works with Outlook, not OE - I'll use Outlook if that'll fix it
(2) How does the routine know I want to send to OE anyway?
(3) Does the CDO library support this functionality from XP?
Thanks,
dave
to an email message to send to a supplier. Someone at the ACCESS newsgroup
suggested the following code:
Public Sub SendMailCDO(ToWHom As String, FromWhom As String, Subject As
String, Body As String, Optional AttachmentPath As String)
Const cdoDefaults = -1
Const cdoIIS = 1
Const cdoOutlookExpress = 2
Dim Message As Object 'CDO.Message
Set Message = CreateObject("CDO.Message")
With Message
'Use dafault config from system
.Configuration.Load -1
.To = ToWHom
If Len(FromWhom) > 0 Then
.From = FromWhom
End If
.Subject = Subject
.TextBody = Body
If Len(AttachmentPath) > 0 Then
.AddAttachment AttachmentPath
End If
.Send
End With
End Sub
I get a runtime error (at the .Send, I imagine) which says that the message
could not be sent to the server.
Can you shed any light on this? A couple of possibilites that have occurred
to me are:
(1) Only works with Outlook, not OE - I'll use Outlook if that'll fix it
(2) How does the routine know I want to send to OE anyway?
(3) Does the CDO library support this functionality from XP?
Thanks,
dave