Using the following code that I got from Andrzejek. I have made some small changes(this is the original), and it works great. Now I have the need to send multiple attachments and I can't figure out how to do that. I think the change is in this bit of code.
ACCESS 10, Windows 7
Public Sub SendAMessage(strFrom As String, strTo As String, _
strCC As String, strSubject As String, strTextBody As String, _
Optional strBcc As String, Optional strAttachDoc As String)
On Error GoTo MyErrorHadler
Set objMessage = New CDO.Message
With objMessage
.From = strFrom
.To = strTo
If Len(Trim$(strCC)) > 0 Then
.CC = strCC
End If
If Len(strBcc) > 0 Then
.BCC = strBcc
End If
''' On behalf of
'.Sender = "Bill.Wolf@msn.com"
.Subject = strSubject
.TextBody = strTextBody
If Len(strAttachDoc) > 0 Then
.AddAttachment strAttachDoc
End If
With .Configuration.Fields
.Item(CDO.cdoSMTPServer) = "NTSMTP.ABC.DEF.XYZ"
.Item(CDO.cdoSMTPServerPort) = 25
.Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With
.Send
End With
Set objMessage = Nothing
Exit Sub
Thanks in advance
jpl
ACCESS 10, Windows 7
Public Sub SendAMessage(strFrom As String, strTo As String, _
strCC As String, strSubject As String, strTextBody As String, _
Optional strBcc As String, Optional strAttachDoc As String)
On Error GoTo MyErrorHadler
Set objMessage = New CDO.Message
With objMessage
.From = strFrom
.To = strTo
If Len(Trim$(strCC)) > 0 Then
.CC = strCC
End If
If Len(strBcc) > 0 Then
.BCC = strBcc
End If
''' On behalf of
'.Sender = "Bill.Wolf@msn.com"
.Subject = strSubject
.TextBody = strTextBody
If Len(strAttachDoc) > 0 Then
.AddAttachment strAttachDoc
End If
With .Configuration.Fields
.Item(CDO.cdoSMTPServer) = "NTSMTP.ABC.DEF.XYZ"
.Item(CDO.cdoSMTPServerPort) = 25
.Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 10
.Update
End With
.Send
End With
Set objMessage = Nothing
Exit Sub
Thanks in advance
jpl