Hello folks!!
I have a very odd issue.
I am using the code to successfully send smtp out of Access 2007.
I establish a connection with the local Access table to pull in the attributes of the message.
One of the attributes is a path and file name to an attachement.
Everything sends fine; no problem with the send.
The problem is that each line of data has a unique attachemnt; a unique file name.
Message loop one gets file A.
Message loop two gets file A and file B.
Message loop three gets file A, file B and file C.
All other attributes are pulled in unique to the associated row or records. The only issue I am experiencing is associated to the attachements.
here is my code:
I have a very odd issue.
I am using the code to successfully send smtp out of Access 2007.
I establish a connection with the local Access table to pull in the attributes of the message.
One of the attributes is a path and file name to an attachement.
Everything sends fine; no problem with the send.
The problem is that each line of data has a unique attachemnt; a unique file name.
Message loop one gets file A.
Message loop two gets file A and file B.
Message loop three gets file A, file B and file C.
All other attributes are pulled in unique to the associated row or records. The only issue I am experiencing is associated to the attachements.
here is my code:
Code:
Public Function SendDashboardMail()
sMailServer = "some mail server"
sMailFromAddress = "some mail address"
Set ObjMessage = CreateObject("CDO.Message")
Set Recordset = CurrentDb.OpenRecordset("tblDASHBOARD_DISTRIBUTION")
Set sToAddress = Recordset.Fields("sMailToAddress")
Set sCCAddress = Recordset.Fields("sMailCC")
Set sSubject = Recordset.Fields("sMailSubject")
Set sBody = Recordset.Fields("sMailBody")
Set sMailAttachment = Recordset.Fields("sProjLabel")
Do Until Recordset.EOF
ObjMessage.Subject = sSubject
ObjMessage.From = sMailFromAddress
ObjMessage.To = sToAddress
ObjMessage.CC = sCCAddress
ObjMessage.TextBody = sBody
ObjMessage.AddAttachment sMailAttachment
ObjMessage.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
ObjMessage.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = sMailServer
ObjMessage.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
ObjMessage.Configuration.Fields.Update
ObjMessage.Send
Recordset.MoveNext
Loop
Recordset.Close
End Function