Results 1 to 7 of 7

Thread: Simple Email

  1. #1
    Join Date
    Sep 2004
    Posts
    33

    Unanswered: Simple Email

    It must be simple but I a noob.

    I have a form and in that form e-mail field is filled with the client email addressm I want to create a commmand button near the email field and when I click on it I want the new mail (microsoft outlook) opened and TO: field filled with the email address of that current client...

    any help please?

  2. #2
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Yes it is possible, no it aint as easy as you think. What version of email client are you using / planning to use? Outlook? Outlook Express? If you wanted it simple why dont you make the email field a hyperlink and on the afterupdate function of that field make it field = "mailto:" & field. If you are using Outlook though I can provide some code which opens up the mail client with the To field populated

  3. #3
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Investigate the SendObject method of the DoCmd object. This has worked well for me where the default mail client is Outlook Express.
    Rod

    fe_rod@hotmail.com

  4. #4
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    Or try this command:

    shell("start mailto:email.address@internet.com")

    Just substitute the email.address@internet.com for the email address that you want to send an email to. this will load the default email program and create the new message with the email address in the To... line.

  5. #5
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Quote Originally Posted by Rod
    Investigate the SendObject method of the DoCmd object. This has worked well for me where the default mail client is Outlook Express.
    Yes, I use SendObject with Outlook with no problem. I have no experience of alternatives but this method allows you to specify recipients, titles, contents attachments (qrys, reports..) etc.

    Example of use in code:

    Code:
    Private Sub myEmailButton_Click()
    Dim myRecipient As String
    myRecipient = Forms![myForm].myEMail
    DoCmd.SendObject , , , myRecipient, , , "Title here", , True
    End Sub
    where myEmail is the control holding the e-mail address and myForm is the form name.

    Chris

  6. #6
    Join Date
    Sep 2004
    Posts
    33
    ok this code works good thanks
    PHP Code:
    Private Sub myEmailButton_Click()
    Dim myRecipient As String
    myRecipient 
    Forms![Orders by Customer].EmailAddress
    DoCmd
    .SendObject , , , myRecipient, , , "Order", , True
    End Sub 
    when i click on the button it enters the email address to outlook new email document but if I cancel sending email and close the new email window access gives me the following error:

    Run time error 2501
    The SendObject action was cancelled and points me to this line in the code
    DoCmd.SendObject , , , myRecipient, , , "Order", , True

    how can i fix that glitch?

  7. #7
    Join Date
    Sep 2004
    Posts
    33
    i added this line and fixed the problem.

    On Error Resume Next

    but if you guys know a betterway please let me know...
    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
  •