• sendobject (VBA/Access2000/sr1)

    Author
    Topic
    #366149

    I am using docmd.sendobject in VBA on an Access form to send an email via Outlook 2000.
    It works PERFECTLY! The only problem is that it only works ONE TIME. Sometimes it works 2 or 3 times, but I can’t determine a pattern or reason for this.

    Here is the code I am using:

    Private Sub Command36_Click()
    DoCmd.SendObject acSendNoObject, , , [Members], , , “New Resident Complaint”, “COMPLAINT: ” & [ComplaintDescription] & “Last Name ” & [ConLastName] & “DATE RECEIVED: ” & [ComplaintReceivedDate], True, “”

    End Sub

    Is there some line of code that would “clear” or “reset” some dll or something that is running in Outlook?
    I don’t really know VBA, I’m just hacking around here. I’m hoping it is a simple line or two. THANK YOU!

    Viewing 0 reply threads
    Author
    Replies
    • #568002

      hi,

      i have no solution to your current problem,
      but i stopped using sendobject a long time ago.

      I now use the Outlook object library, and that one always works
      Here is an example:

      ‘*************************************************************
      ‘* Set a reference to ‘Microsoft Outlook 9.0 Object Library *
      ‘* (or any other version) *
      ‘* Menu ‘Tools’, ‘References’, check the appropriate library *
      ‘*************************************************************

      Private Sub cmdSendMail_Click()
      Dim ol As New Outlook.Application
      Dim olMail As Outlook.MailItem
      Dim strCC As String

      ‘strCC = “address1@domain.com” & “;” & “address2@domain.com”

      Set olMail = ol.CreateItem(olMailItem)

      With olMail
      .To = “some.address@domain.com”
      ‘.CC = strCC
      ‘.BCC = “address2@aa.com”
      ‘.Attachments.Add “c:somefile.txt”
      ‘.Attachments.Add “c:anotherfile.txt”
      .Subject = “Testing”
      .Body = “This is the body…”
      .Display
      ‘.Send
      End With

      Set olMail = Nothing
      Set ol = Nothing

      End Sub

      btw, make sure u
      cheers
      Ricky

      • #569049

        THANK YOU THANK YOU THANK YOU!!
        That sendobject was going to be the end of me. Works like a charm every time.

      • #636879

        Hi,

        I know this is an old thread, but I was wondering how to insert a mailmerge document as the body of the email (not as an attachment). When I use the code you provided, I only get the document name as the body. Hope you can help!

        Thanks,
        Lisa

    Viewing 0 reply threads
    Reply To: sendobject (VBA/Access2000/sr1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: