Ok, so a few of you most helpful members got me up and running with SMTP and a few days later, my port has been shut down by my provider. <sad face>
So, I want to move this to actually creating the messages natively in Outlook and then clicking send.
Problem is, the message does display, but when I click send, it shows up in my sent items, but neveractually gets sent.
I think the code is good but some local security policy is preventing the item from sending, but I wanted to run it by the experts, first.
Best regards,
-boggsie
So, I want to move this to actually creating the messages natively in Outlook and then clicking send.
Problem is, the message does display, but when I click send, it shows up in my sent items, but neveractually gets sent.
Code:
Option Explicit
Public Function SendDashboardMail()
Dim Recordset As DAO.Recordset
Set Recordset = CurrentDb.OpenRecordset("LocalDatabase")
Do Until Recordset.EOF
SendMail Recordset.Fields("sMailToAddress"), _
Recordset.Fields("sMailCC"), _
Recordset.Fields("sMailSubject"), _
Recordset.Fields("sMailBody"), _
"C:\Data\_Files\" & Recordset!sProjLabel & "_transport_" & Format(Date, "YYYY-MM-DD") & ".xls"
Recordset.MoveNext
Loop
Recordset.Close
End Function
Public Sub SendMail(sToAddress, sCCAddress, sSubject, sBody, sMailAttachment)
Dim objMessage As Object
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set objMessage = CreateObject("CDO.Message")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.Subject = sSubject
.To = sToAddress
.Body = sBody
.Attachments.Add sMailAttachment
.Display
End With
End Sub
I think the code is good but some local security policy is preventing the item from sending, but I wanted to run it by the experts, first.
Best regards,
-boggsie