Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    e mail code (2000)

    Hello, want to trigger an e mail on a form event that is populated with detail taken from the form. I am ok to a point but falling down with the code when the detaild is from a field on the subform e.g. code
    DoCmd.SendObject to:="", Subject:="Technical Helpline Survey " & Me!MainID, _
    MessageText:=vbCrLf & vbCrLf & vbCrLf & "Technical Consultant:" & " " & Me![TCH Name] _
    & vbCrLf & vbCrLf & "Case Surname:" & " " & Me.....this is where I come unstuck. There is a control field on the subform and not sure how to code.

    In addition how can i code so the to field on the e mail is pre populated, there is a field on the form that has the recipient name in. Finally can I set the e mail, by code to request a reply.

    Many thanks Darren.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: e mail code (2000)

    1) To refer to a control on a subform, you use

    Me!SubformName!ControlName

    where SubformName must be the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window. If you open the main form in design view and click once on the subform, you'll see the control name in the Formatting toolbar and in the title bar of the Properties window.

    2) You leave the To field blank because you have To:="". Change this to To:=Me!ControlName where ContrlName is the name of the appropriate control.

    3) What do you mean by "request a reply"? Do you mean a read receipt? DoCmd.SendObject doesn't let you specify that.

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: e mail code (2000)

    Hans, those answers are great, thank you. Is ir possible however to issue a saved .oft pre formatted e mail and load onto that certain detail from the database?

    Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: e mail code (2000)

    In order to use a specific .oft template, you must use Automation to control Outlook from Access. If you search for Outlook.Application in this forum, you'll find several examples.

    To create a new mail based on a template, you'd use code like this:

    Dim olApp As Outlook.Application
    Dim olMsg As Outlook.MailItem
    Set olApp = CreateObject("Outlook.Application")
    Set olMsg = olApp.CreateItemFromTemplate("C:Statusrep.oft")
    With olMsg
    .Subject = "Technical Helpline Survey " & Me!MainID
    .To = Me!txtRecipient
    ...
    .Display ' or .Send
    End With
    Set olMsg = Nothing
    olApp.Quit
    Set olApp = Nothing

  5. #5
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: e mail code (2000)

    Thanks again Hans for your valuable support.

    Darren.

Posting Permissions

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