how to send email from access form via outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmedamer
    New Member
    • Jan 2014
    • 6

    how to send email from access form via outlook

    what's the required code to send Email from access form and the record be attached?
    to [contractorEmail]
    cc [ContracHolderEm ail]
    Last edited by zmbd; Oct 28 '14, 02:57 PM. Reason: [z{please note> outright requests for code may be deleted, please show your work when asking for help(^_^) }]
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    There are numerous methods to do this. What have you tried so far? We will not create the solution for you but are more than willing to troubleshoot any problematic code you may have.

    Comment

    • Ahmedamer
      New Member
      • Jan 2014
      • 6

      #3
      ok
      i used the the following code to send Email
      i need to add cc and body of message from another record
      Code:
      Private Sub Command88_Click()
         
      
          Dim stWhere As String       '-- Criteria for DLookup
          Dim varTo As Variant        '-- Address for SendObject
          Dim stText As String        '-- E-mail text
          Dim RecDate As Variant      '-- Rec date for e-mail text
          Dim stSubject As String     '-- Subject line of e-mail
          Dim stID As String            '-- The  ID from form
          Dim stWho As String         '-- Reference to tblUsers
          Dim stApprovedBy As String    '-- Person who approved Violation
          Dim strSQL As String        '-- Create SQL update statement
          Dim errLoop As Error
      
          '-- Combo of names to assign ticket to
          stWho = Me.ApprovedBy
          stWhere = "tblApprovedBy.ApprovedBy"
          '-- Looks up email address from tblApprovedBy
          varTo = DLookup("[EMail]", "tblApprovedBy", stWhere)
      
      
          stSubject = ":: New Violation ::"
      
          stID = Format(Me.ID, "00000")
          RecDate = Me.Date
          '-- User who prepare violations
          strUserName = Me.UserName.Column(1)
      
      
          stText = "You have been recieved a new violation." & Chr$(13) & _
                   Chr$(13) & "Violation number: " & ID & Chr$(13) & _
                   "This Violation has been sent to you for Approval by: " & strUserName & _
                   Chr$(13) & "Received Date: " & RecDate & Chr$(13) & _
                   Chr$(13) & "This is an automated message." & _
                 " Please do not respond to this e-mail."
      
          'Write the e-mail content for sending to assignee
          DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
          
        
      
      End Sub
      Last edited by zmbd; Oct 28 '14, 02:54 PM. Reason: [z{placed code tags}]

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        Ahmedamer,

        Please use the Code Tags when posting code.

        Does this code work?

        My guess is your code for:

        Code:
        stWhere = "tblApprovedBy.ApprovedBy"
         varTo = DLookup("[email]", "tblApprovedBy", stWhere)
        Will either produce an error or not return any results.

        stWhere should be something like:

        stWhere = "[ApprovedBy] = '" & stWho & "'"

        Is there anything else you need help with on this code?
        Last edited by zmbd; Oct 28 '14, 02:56 PM. Reason: [z[placed inline code tags}]

        Comment

        Working...