Question : Send Emails Via MS Access Form

Hi,

I would like to ask if it is possible to send emails using MS Access forms. I have attached a sample of what we want to do, basically it will be like an html form but instead of writing down the body and subject, they will be coming from a table in an MS Access dbase. Also the code should contain the sender and receiver information.

If this is possble, can anyone send me the procedure on how to do this?

As a part of this I would like to ask a way to merge fields in a textbox in an MS Access Query but with line break. I know how to merge fields in a staright line which is this:

Select Field1 & Field2 & Field 3 AS Subject

But what if I would like to arrange them in one textbox but Field1 value will be in line 1, Field2 value will be in line 2 and Field3 value will be in line 3?

e.g.
Field 1 Value
Field 2 Value
Field 3 Value


Thanks

Answer : Send Emails Via MS Access Form

To add line breaks, work this into the end of each line: Chr(13), like this:

Field1 & Chr(13)  & Field2 & Chr(13) & Field 3

(You will need to use the combined  Chr(13) & Chr(10) if the resultant string is passed to, for example, a text editor that needs both the carriage return and linefeed, but just Chr(13) if sending to the SendObject method below.)

Example of how to send e-mail in Access via VBA. This uses the user's MAPI client and sends no attachment, but can also be used to send an attachment. Look up the help on the SendObject method for specifics on the usage of each of its arguments (subject, message body, attachment name, format, etc.)

Private Sub MessageSend()
Dim strSubject as String
Dim strBody as String
Dim strRecipient as String

strSubject = DLookup("[CustomerSubject]","[Customer]","[CustomerID] = " & CustomerID)
strBody = DLookup("[Field1]","[Customer]","[CustomerID] = " & CustomerID)
strBody = strBody  & Chr(13) & Chr(10)
strBody = DLookup("[Field2]","[Customer]","[CustomerID] = " & CustomerID)
strBody = strBody  & Chr(13) & Chr(10)
strBody = DLookup("[Field3]","[Customer]","[CustomerID] = " & CustomerID)
strRecipient = DLookup("[CustomerEmailAddress]","[Customer]","[CustomerID] = " & CustomerID)
'send the message
  DoCmd.SendObject acSendNoObject, , , strRecipient, , , strSubject, strBody, False, False

End Sub
Random Solutions  
 
programming4us programming4us