Results 1 to 6 of 6
  1. #1
    Alpana is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    11

    Sending customized e mails on update

    I have designed an Access database with a certain table called EmailAlerts. This table has two fields: EmailMessage and Recipients. The EmailMessage field stores the body of the mail to be sent to the corresponding email addresses in Recipients. For eg:
    EmailMessage | Recepients
    Hello | abc@xyz.com


    Goodbye | pqr@xyz.com

    Now what I want to do is, whenever a record is added to this table, I want to send the email to the corresponding recipient. How can I do this?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    You are adding records through a bound form?

    Search this forum on topic 'email', there are a lot of threads.
    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
    Alpana is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    11
    No, I am adding records using an append query... However, I could resort to bound forms if required...

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    I have never used unbound form for data entry. However, doesn't matter. In the event that saves record, include code to send email or to call a public procedure with the email code.

    Here is one thread https://www.accessforums.net/import-...ook-18221.html
    Last edited by June7; 01-20-2012 at 03:45 PM.
    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.

  5. #5
    Alpana is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    11
    Thanks. Your suggestion helps. Still, I am having a little problem using the code suggested by you. I actually referred to the suggested thread, where I found this link:
    http://www.blueclaw-db.com/access_em...nd_outlook.htm

    I implemented a similar code, as follows:

    Sub Command20_Click()
    Dim mess_body As String
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
    .BodyFormat = olFormatRichText
    .To = Query10.EmailAdd
    .Subject = Query10.CODE
    .HTMLBody = Query10.Description
    .Send
    End With
    Exit Sub
    email_error:
    MsgBox "An error was encountered" & vbCrLf & "The error message is: " & Err.Description
    Resume Error_Out
    Error_Out:
    End Sub

    However, when I am trying to run this code, I am getting a 'Run time error 424:Object required' for the lines:
    .To = Query10.EmailAdd
    .Subject = Query10.CODE
    .HTMLBody = Query10.Description

    Basically, the code cannot access Query10, which is a simple select query.
    How do I solve this?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,970
    You have to open a recordset of the query. Your code does not do that.

    The BlueClaw sample code opens a clone recordset, that is a recordset that is a replicate of the open form's recordset. If you want to refer to a query object, instead of the RecordsetClone method, open a recordset of the query.

    Set rst = CurrentDb.OpenRecordset("Query10", dbOpenDynaset)

    Then you can cycle through the recordset to either build a single TO or BCC (the TO addressee would be yourself) string for multiple addressees or send individual email to each addressee.
    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.

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

Similar Threads

  1. Send e-mails using Access
    By Dotty in forum Queries
    Replies: 4
    Last Post: 09-30-2011, 09:22 PM
  2. Customized Scroll Bar
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:26 PM
  3. Customized Toolbars
    By croydon in forum Programming
    Replies: 4
    Last Post: 10-07-2009, 11:05 AM
  4. Changing the way my Sendmail function sends e-mails
    By slaterino in forum Programming
    Replies: 1
    Last Post: 04-29-2009, 12:40 PM
  5. customized menu bar
    By marianne in forum Access
    Replies: 13
    Last Post: 04-12-2009, 09:47 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