Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2008
    Posts
    150

    Unanswered: Email notification sent to sender from address entered in field

    Hi,

    I am in desperate need of a way to automatically send a notification email to a user when a work order has been assigned.

    I have the fields “Assignee” and “Assig_Email” created in my work order input form. I would like an email to be sent to the individual entered in the Assignee field using the email address entered in the Assign_Email field.

    I have seen some shared code on the Internet, but it was using lookup tables and was way too complex for my Access or VB experience.

    Any code to share or suggestions would really be appreciated.

    Thanks.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Have a look see at the sendobject method. Try something like:
    Code:
    Dim strEmail As String, _
        strSubject As String, _
        strMessage As String
    strEmail = Me.assig_email
    strSubject = "New Work Order"
    strMessage = "Dear " & Me.assignee & "," & vbNewLine & _
                    "This is an automated email to let you know you have a new work order.  Have a nice day."
    DoCmd.SendObject acSendNoObject, , , strEmail, , , strSubject, strMessage, False
    Me.Geek = True

  3. #3
    Join Date
    Sep 2008
    Posts
    150
    Too cool!

    Thanks for the code Nick. I really appreciate it.

  4. #4
    Join Date
    Sep 2008
    Posts
    150

    Disable Debug Form for Outlook Security Form

    Hi Nick,

    I was wondering if there is a way to stop the “Microsoft Visual Basic” debug form from appearing when I click on the “No” button on the Outlook Security form?

    Is there someway to have the Outlook Security form just disappear and return focus to my field?

    Here is the code (provided by you) that I modified for my email notification.

    Private Sub Send_Button_Click()

    Dim strEmail As String, _
    strSubject As String, _
    strMessage As String

    strEmail = Me.Assig_Email
    strSubject = "New WO Problem Report"
    strMessage = Me.Assignee & "," & vbNewLine & vbNewLine & _
    "This is an automated email to notify you that you have been assigned the following WO Problem Report." & vbNewLine & vbNewLine & _
    "PR Number: WO" & Me.PR_Num & vbNewLine & _
    "PR Title: " & Me.Title & vbNewLine & _
    "Location: " & Me.Location & vbNewLine & _
    "PR Type: " & Me.PR_Type & vbNewLine & _
    "Originator: " & Me.Originator & vbNewLine & _
    "Desk Phone: " & Me.Orig_Desk_Phone & vbNewLine & _
    "Mobile: " & Me.Orig_Mobile & vbNewLine & _
    "Fax: " & Me.Orig_Fax & vbNewLine & _
    "Email: " & Me.Orig_Email & vbNewLine & ""

    DoCmd.SendObject acSendNoObject, , , strEmail, , , strSubject, strMessage, False

    End Sub

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    That was a security feature that Bill decided to put in to prevent malicious code from sending emails in your name. Here's an article that might be helpful to you.
    Me.Geek = True

  6. #6
    Join Date
    Sep 2008
    Posts
    150
    Yes, I understand about the Security warning message. I read seveal posts on this issue. Is there a way to disable the debug form that pops-up when the "No" button is clicked. I don't want users to see a debug window each time they click on the "No" button.

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    Oh that! sorry, misunderstood your question. The answer is error handling. Do like this:
    Code:
    on error resume next
    DoCmd.SendObject acSendNoObject, , , strEmail, , , strSubject, strMessage, False
    Should fix it.
    Me.Geek = True

  8. #8
    Join Date
    Sep 2008
    Posts
    150

    Smile

    As usual, you are the best Nick! Thanks again.

Posting Permissions

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