Results 1 to 4 of 4
  1. #1
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Sending e-mail on After Update Event on Form

    Hi,



    I'm trying to send an e-mail on the After Update Event on a date field in a Form. I then want to send the e-mail to the name on that form.

    The Name field is populated via a dropdown list, source of which is a table that also contains e-mail addresses.

    I also want the body of the e-mail to contain 2 other fields in the form.


    I have been trying to do this using the 'sendobject' action in a macro, but am getting nowhere fast.

    Does anyone have experience with this? If so could you please give me an example of code that you are using?

    Thanks,
    Kirsti

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Why SendObject and macro and not the VBA procedure from your other thread?

    I don't use macros but should be able to concatenate the data into the SendObject arguments.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Hi June7,

    I didn't want to use the VBA procedure from my other thread because it requires each user to save code in a module in Outlook which is in the too hard basket for most of my users.

    I have decided on VBA rather than a macro though, and I'm half way there with the code. I'll repost when I either have the code completed, or need help! Thanks.

  4. #4
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Ok, I have it working using this code:

    Private Sub Field5_AfterUpdate()
    Dim sSubject As String
    Dim stMail As String
    Dim strBody As String

    'message subject
    sSubject = "My Message Subject"
    'sends email to name in Field1 on the current form
    stMail = DLookup("[Field1]", "tblTable1", "[Field1]= Forms![frmMyForm]![Field1]")
    'email body contains Field2 and Field3 from current form
    strBody = "MyText " & Forms![MyForm]![Field2] & " " & _
    DLookup("[Field1]", "tblTable2", "[Field1]= Forms![frmMyForm]![Field3]") & _
    " MyText"

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.SendObject acSendNoObject, , , stMail, , , sSubject, strBody, True

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sending Report via E-mail Error
    By Nettie in forum Access
    Replies: 8
    Last Post: 04-06-2012, 12:15 PM
  2. Replies: 11
    Last Post: 09-12-2011, 11:30 AM
  3. Replies: 1
    Last Post: 05-10-2011, 09:48 AM
  4. Sending Outlook E-mail - Run-time error '429'
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 03-01-2011, 09:30 AM
  5. Sending mail automatically
    By carstenhdk in forum Forms
    Replies: 1
    Last Post: 05-31-2010, 04:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums