Using SendObject to e-mail a report (Access / Outlook 2003)

callen82

New member
Local time
Today, 01:21
Joined
Dec 21, 2012
Messages
3
Hi all,

I have recently taken over a project at work to develop a database from a colleague and have hit a stumbling block on the following module that was originally written to send an Access report as an e-mail attachment.

I have used it to add in a routine which saves a copy of the report on our network, and this part appears to be working reliably, however only some of our machines are successfully executing the code to send the report via e-mail using the SendObject command. All machines are running Office 2003 SP3 on Windows XP SP3.

The following is the module extracted to a text file:

Code:
Attribute VB_Name = "mdlSendEmail"
Option Compare Database

'sends rejection report e-mails and saves copy to shared area

Public Function Sendrpt3()
Dim variableCC As String
Dim Scheme As String
Dim Street As String
Dim Packref As String
Dim datestamp As String
Dim Filename As String

On Error Resume Next

Scheme = Forms!frmpackdata.txtAsset
Street = Forms!frmpackdata.TxtStreet
Packref = Forms!frmpackdata.txtPack
datestamp = Format(Now, "yyyyMMdd-hhmmss")
Filename = "network path\reports\" & datestamp & "-" & Packref & ".snp"

    DoCmd.OutputTo acReport, "rptESRIReport", "SnapshotFormat(*.snp)", Filename, False, "", 0


    If Forms!frmpackdata!txtCoord = "" Then
        variableCC = ""
    Else
        variableCC = Forms!frmpackdata!txtCoord & "@companyname.com"
    End If
    
    ' handle scenario where the above lines still only returns the e-mail domain name @companyname.com
    If variableCC = "@companyname.com" Then
        variableCC = ""
    End If
    
    DoCmd.SendObject acReport, "rptESRIReport", "SnapshotFormat(*.snp)", Forms!frmpackdata!txtOneNet & "@companyname.com", Forms!frmpackdata!txtTeamLeader & "@companyname.com" & "; " & variableCC, "di.audit@companyname.com", "QA Audit Rejection - Pack Ref " & Packref & ": " & Scheme & " - " & Street, "", True, ""
 
End Function

I'm at a bit of a loss as to how this seems to be executing fine on some machines and not others, are there any known issues with the SendObject command in Office 2003 which would explain this behaviour and is there a better, more reliable method of achieving it?
 
Try to set the error handling out of function, to se where the problem occurs[FONT=&quot].[/FONT][FONT=&quot][/FONT]
 

Users who are viewing this thread

Back
Top Bottom