Log in

View Full Version : Send Reports by Email from MS Access using SMTP



Dominique
01-21-2011, 11:08 AM
Hello,
I am trying to send a report as attachment in an email using a VBS Script scheduled:
SendEmailCDO wsh.arguments(0), strMessage, strSubject, strAttachSub SendEmailCDO(ByVal strTo, ByVal strMessage, ByVal strSubject, ByVal strAttach)
Dim objEmail
' On Error Resume Next
Set objEmail = CreateObject("CDO.Message")
'StopobjEmail.FROM = email
objEmail.To = strTo
objEmail.Subject = strSubjectobj
Email.TextBody = strMessage
If strAttach <> "" Then objEmail.AddAttachment strAttach
objEmail.Configuration.Fields.Item("schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("schemas.microsoft.com/cdo/configuration/smtpserver") = "mitsmail"
objEmail.Configuration.Fields.Item("schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Comment out Authentication++' objEmail.Configuration.Fields.Item("schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1' objEmail.Configuration.Fields.Item("schemas.microsoft.com/cdo/configuration/sendpassword") = objEmail.Configuration.Fields.Update
objEmail.Send
If Err.Number <> 0 Then
MsgBox "Error in sending. " & Err.Description
Else
MsgBox "Sent"
End If
Set objEmail = Nothing
End Sub

The script works fine when I pass a txt file as the 4th parameter but does not work with an MSAccess Report.What is the link to get an MSAccess report?Thanks,
Dom

gcomyn
01-27-2011, 12:09 PM
As far as I know, you have to print the Access report to a PDF file, then send that. I don't know of anyway that you can take the report directly from Access.

GComyn
:sleuth:

geekgirlau
01-27-2011, 04:42 PM
GComyn is correct - you have to have a file to send, which means you have to export the MS Access report to another format. Doesn't have to be PDF - RTF or other format will work as well.