email data from form

  • Thread starter Thread starter Brian C
  • Start date Start date
B

Brian C

I have a form in which a user can type data plus an email
address and I then want to send that data to the email as
a message.

Can I do this in ACCESS and if so how or where can I find
an example? Thanks
 
Requires that your references include Microsoft CDO for Windows 2000 Library
and Microsoft ActiveX Objects 2.5 Library, but here it is:

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
Set Flds = iConf.Fields

' Set the configuration
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "mail.example.com"

' ... other settings
Flds.Update

Dim iMsg As New CDO.Message
Set iMsg.Configuration = iConf

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iMsg As New CDO.Message

' configure message here if necessary
With iMsg
.To = "(e-mail address removed)"
.From = "(e-mail address removed)"
.CC = (e-mail address removed)
.Subject = "Test"
.TextBody = "Body of Message"
.AddAttachment "\\server\share\file.txt"
.Fields(cdoDispositionNotificationTo) = "(e-mail address removed)"
' finish and send
.Fields.Update
.Send
End With
Set iMsg = Nothing


Depending on what your doing you might need to concantonate the user entries
to populate the fields. ie,
strUserInput = txtText1 & " " & TxtText2 &, etc
strUserInput2 = "Sincerely, " & txtText3
then use, for example,
..TextBody = strUserUnput & vbcrlf & strUserUnput2 & vbcrlf
Note this is just an example and I made the text info up.
 
Hmm I only seem to have MS CDO for Exchange 2000 in my
available references from Tools, References in VBE. Will
this do or how do I get the Windows 2000 version?

I had MS ActiveX Objects 2.1 Library ticked so I assume I
untick it and tick the 2.5 version
 
Back
Top