Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2010
    Posts
    13

    DoCmd.SendObject Question

    Hi all,



    I am have a question concerning the use of the SendObject function. I am using a database that has two buttons to send e-mails. The first button sends an e-mail with text that it gets from an open form, and the second button sends an email with a report as a PDF attached. This database is used on several computers at our offices, and the problem is the that first button works on all the computers; however, the second only works on about half of them.

    I thought maybe the email client was not set up properly, but button 1 works so that leads me to discredit that notion. The only other difference I see is that button 2 involves a report which might be the cause of the issue. I'm wondering if anybody knows why this is happening and how to fix it or a different approach that would circumvent the problem

    Code for button 1:

    Private Sub SendEmailToAssignedTo_Click()
    'Variables to hold e-mail addresses
    Dim ToEmailAddress As String
    Dim AffectedBy1 As String
    Dim AffectedBy2 As String
    Dim AffectedBy3 As String
    Dim CCEmailAddresses As String

    'Assign the Assigned To email adress to a variable
    ToEmailAddress = IIf([Assigned To] = 17, "", Nz(DLookup("[EMailAddress]", "Contacts", "ID=" & Nz([Assigned To], 0))))

    'Assign the affected by e-mail addresses to variables
    AffectedBy1 = IIf([Affected By-1] = 17, "", Nz(DLookup("[E-Mail Address]", "Contacts", "ID=" & Nz([Affected By-1], 0))))
    AffectedBy2 = IIf([Affected By-2] = 17, "", Nz(DLookup("[E-Mail Address]", "Contacts", "ID=" & Nz([Affected By-2], 0))))
    AffectedBy3 = IIf([Affected By-3] = 17, "", Nz(DLookup("[E-Mail Address]", "Contacts", "ID=" & Nz([Affected By-3], 0))))

    'Combine all threee email address into one variable adding semicolons if necessary
    If AffectedBy1 <> "" Then
    CCEmailAddresses = AffectedBy1
    End If

    If AffectedBy2 <> "" And AffectedBy1 <> "" Then
    CCEmailAddresses = CCEmailAddresses & "; " & AffectedBy2
    ElseIf AffectedBy2 <> "" Then
    CCEmailAddresses = AffectedBy2
    End If

    If AffectedBy3 <> "" And AffectedBy2 <> "" And AffectedBy1 <> "" Then
    CCEmailAddresses = CCEmailAddresses & "; " & AffectedBy3
    ElseIf AffectedBy3 <> "" And AffectedBy2 <> "" Then
    CCEmailAddresses = CCEmailAddresses & "; " & AffectedBy3
    ElseIf AffectedBy3 <> "" And AffectedBy1 <> "" Then
    CCEmailAddresses = CCEmailAddresses & "; " & AffectedBy3
    ElseIf AffectedBy3 <> "" Then
    CCEmailAddresses = AffectedBy3
    End If

    'Allows proper operation if e-mail is closed without sending
    On Error Resume Next
    'Sends information to default e-mail program
    DoCmd.SendObject , , , ToEmailAddress, _
    CCEmailAddresses, "mmccoy@hunter.com; slochmann@hunter.com", "ECO# " & [Title], _
    [Forms]![Issues]![ECO Description] & "; " & [Forms]![Issues]![Comment], True
    End Sub

    Code for Button 2:

    Private Sub cmdSendEmail_Click()

    'Variable to hold email address
    Dim strToEmailAddress As String

    'Get email address
    strToEmailAddress = Nz(DLookup("[E-Mail Address]", "Contacts", "ID=" & Nz([cboSendEmailTo], 0)))

    'Ensures proper operation if email is closed without saving
    On Error Resume Next

    'Sends Email
    DoCmd.SendObject acSendReport, "Issue Details By Assigned", acFormatPDF, strToEmailAddress, , , _
    "Issues Report", "Issues Report is attached", True

    'Closes form
    'DoCmd.Close acForm, Me.Name
    End Sub


    Thanks in advance

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    The only thing I can think of offhand is that you are using an older version of the Runtime on some of the computers.

    Access didn't support PDFs as a filetype (at least not natively) before Access 2007, so if you're using 2000 or 2003 on some of the computers, they wouldn't know how to make PDFs.

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    I even think that with Access 2007 you still have to install the addin SaveAsPDFandXPS before you can use the pdf format. Could be included in SP2.

    grNG

  4. #4
    Join Date
    Oct 2010
    Posts
    13
    Thanks everyone,

    The problem pcs did not have the add-in. I verified this by leaving the format parameter for the SendObject function blank and when the file type selection box opened there was no option for PDF. Thanks again for your help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple Reports in cmd.SendObject
    By Steven.Allman in forum Access
    Replies: 1
    Last Post: 06-21-2010, 09:59 AM
  2. SendObject
    By weshader in forum Access
    Replies: 1
    Last Post: 11-09-2009, 04:19 PM
  3. Email sent via DoCmd.SendObject
    By silverback in forum Programming
    Replies: 0
    Last Post: 10-29-2009, 06:26 AM
  4. SendObject Message
    By williammarino in forum Forms
    Replies: 4
    Last Post: 10-06-2009, 01:54 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums