424,294 Members | 1,916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,294 IT Pros & Developers. It's quick & easy.

how to send email from access form via outlook

P: 6
what's the required code to send Email from access form and the record be attached?
to [contractorEmail]
cc [ContracHolderEmail]
Oct 28 '14 #1
Share this Question
Share on Google+
3 Replies


twinnyfo
Expert Mod 2.5K+
P: 2,894
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.
Oct 28 '14 #2

P: 6
ok
i used the the following code to send Email
i need to add cc and body of message from another record
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command88_Click()
  2.  
  3.  
  4.     Dim stWhere As String       '-- Criteria for DLookup
  5.     Dim varTo As Variant        '-- Address for SendObject
  6.     Dim stText As String        '-- E-mail text
  7.     Dim RecDate As Variant      '-- Rec date for e-mail text
  8.     Dim stSubject As String     '-- Subject line of e-mail
  9.     Dim stID As String            '-- The  ID from form
  10.     Dim stWho As String         '-- Reference to tblUsers
  11.     Dim stApprovedBy As String    '-- Person who approved Violation
  12.     Dim strSQL As String        '-- Create SQL update statement
  13.     Dim errLoop As Error
  14.  
  15.     '-- Combo of names to assign ticket to
  16.     stWho = Me.ApprovedBy
  17.     stWhere = "tblApprovedBy.ApprovedBy"
  18.     '-- Looks up email address from tblApprovedBy
  19.     varTo = DLookup("[email]", "tblApprovedBy", stWhere)
  20.  
  21.  
  22.     stSubject = ":: New Violation ::"
  23.  
  24.     stID = Format(Me.ID, "00000")
  25.     RecDate = Me.Date
  26.     '-- User who prepare violations
  27.     strUserName = Me.UserName.Column(1)
  28.  
  29.  
  30.     stText = "You have been recieved a new violation." & Chr$(13) & _
  31.              Chr$(13) & "Violation number: " & ID & Chr$(13) & _
  32.              "This Violation has been sent to you for Approval by: " & strUserName & _
  33.              Chr$(13) & "Received Date: " & RecDate & Chr$(13) & _
  34.              Chr$(13) & "This is an automated message." & _
  35.            " Please do not respond to this e-mail."
  36.  
  37.     'Write the e-mail content for sending to assignee
  38.     DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
  39.  
  40.  
  41.  
  42. End Sub
Oct 28 '14 #3

twinnyfo
Expert Mod 2.5K+
P: 2,894
Ahmedamer,

Please use the Code Tags when posting code.

Does this code work?

My guess is your code for:

Expand|Select|Wrap|Line Numbers
  1. stWhere = "tblApprovedBy.ApprovedBy"
  2.  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?
Oct 28 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.