Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011
    Posts
    23

    Question Unanswered: Automation Help: Email from Access 03 to Outlook 07

    This is a two part question.

    Part 1)

    The code Im using (listed below) creates and sends an e-mail but in my sent items the sent email doesnt display a recipient name and i get a response from admin saying (STAFFNAME is actually a member of staffs e-mail address removed for this post)

    Your message did not reach some or all of the intended recipients.

    Subject: Holiday Request
    Sent: 17/11/2011 09:44

    The following recipient(s) cannot be reached:

    STAFFNAME on 17/11/2011 09:44
    This message could not be sent. Try sending the message again later, or contact your network administrator. Error is [0x80070057-00000000-00000000].
    CODE:
    Code:
    Set objOutlook = CreateObject("Outlook.Application")
       Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
       With objOutlookMsg
          Set objOutlookRecip = .Recipients.Add("STAFFNAME")
          objOutlookRecip.Type = olTo
          .Subject = "Holiday Request"
          .Body = "Test" & vbCrLf
          For Each objOutlookRecip In .Recipients
             If Not objOutlookRecip.Resolve Then
                objOutlookMsg.Display
             End If
          Next
          .Send
       End With
       Set objOutlookMsg = Nothing
       Set objOutlook = Nothing
       Set objOutlookRecip = Nothing
       Set objOutlookAttach = Nothing
       
       Exit Sub
    Part 2)

    How can I select information from a queary to populate the relevant fields?

    I have tried some variations in the body part of the e-mail as a test but no luck so far

    example
    Code:
    qryEmail_CompleteBookingDetails].[qryEmail_Staff&Booking].[HolType]
    Would it be easier to open a form based on the results of the query and do an event procedure on gotfocus to send the email?

    thanks
    Last edited by Random Invert; 11-17-11 at 14:10.

  2. #2
    Join Date
    Apr 2011
    Posts
    23
    1)

    Code:
    DoCmd.SendObject
    Seems to have solved my e-mail issue although it does leave me with the Outlook Automated e-mail warning.

    2)

    Code:
    Variable = DLookup("FieldName","Table/Query","ID =" &FormID)
    Seems to have solved my query issue.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •