Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Want to send email from access 2003 (2003)

    Hi,

    I'm a fairly new user of Access (2003) and have built a database which includes a form "Company" with a sub form "Contacts". I want to add a button to the subform which will send an email to the specified contact. I have virtually no knowledge of VB but managed to find the code which opens Outlook: DoCmd.SendObject.
    What I want to do now is have the email address of the contact automatically inserted into the "To" field of the Outlook email.
    I did try the following - DoCmd.SendObject To:=Me!TestTable!EmailName
    which I found on a message thread somewhere on this board, but I get an error message saying "Invalid Use of Me keyword" (in fact every time I've tried to use the "Me" expression I've got the same message).

    I would really appreciate anyone's help with this....I've trawled through so many message boards (including this one!) for all the code I need to make this work and I just can't seem to make it happen!

    Sorry if this is a really basic question, but I am at my wit's end with it....

    Many thanks

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

    Re: Want to send email from access 2003 (2003)

    Welcome to Woody's Lounge!

    Is the code you're writing in the code module for the subform? If so, you should be able to use Me. However, if your code is in a standard module (the kind you can see in the Modules tab of the database window), you can't use Me.

    Assuming for the moment that the code is in the subform module: is EmailName a field in the record source of the subform? If so, try
    <code>
    DoCmd.SendObject To:=EmailName ...
    </code>
    or
    <code>
    DoCmd.SendObject To:=Me.EmailName ...</code>

  3. #3
    New Lounger
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Want to send email from access 2003 (2003)

    Hi Hans,

    Thank you so much for your speedy reply!

    Actually I have just been using the standard module (so builidng a Macro which reads the module and linking the button on the form to the Macro). I didn't realise that you could have a module on the subform - how do I access this?

    EmailName is the field in which the records are stored.

    Thanks

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

    Re: Want to send email from access 2003 (2003)

    Open the subform in design view.
    Select the command button.
    Activate the Event tab of the Properties window.
    Click in the On Click event.
    Select [Event Procedure] from the dropdown list.
    Click the builder button (the ... to the right of the dropdown arrow).
    This will take you to the code module for the subform.
    Access has already created the first and last line of the event procedure for you.
    You can enter your code in between; you can refer to the subform itself as Me here.

  5. #5
    New Lounger
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Want to send email from access 2003 (2003)

    Hans...I can't thank you enough! It finally works!!

    Very much appreciated!

Posting Permissions

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