add form info to HTML email

B

BigDog

OK. With help, I was able to get access to send an HTML email. Now I just
need to get the record to be passed. I know this is probably VERY simply
but I lost :) Thx
 
A

Arvin Meyer [MVP]

Pass the data as a string in the body of the email:

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

Dim strTo as String
Dim strSubject As String
Dim strBody As String

strTo = Me.txtEmail
strSubject = "This is a sample"
strBody = "Name " & Me.txtName & vbCrLf & _
"Address " & Me.txtAddress & vbCrLf & _
"More data, etc. " & Me.txtWhatever

With objEmail
.To = strTo
.Subject = strSubject
.body = strBody
 
B

Bill

But how do get the HTML features, like bolding, etc? I'm thinking something
like:

strHTMLBody = <HTML><Body> "<b>Name /b>" & Me.txtName & vbCrLf & _
"Address " & Me.txtAddress & vbCrLf & _
"More data, etc. " & Me.txtWhatever</body></html>

But this doesnt make any sense....
 
B

Bill

This is what I have so far. How/where can I put the tags??:

Private Sub Command125_Click()
'Creates a new e-mail item and modifies its properties.

Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>Enter the message text here. & Me.[Check-out
Date] </BODY></HTML>"
.Display
End With

End Sub
 
A

Arvin Meyer [MVP]

However you did it before, is the same way you do now, except using the
objMail object in your code. I do not use HTML mail because many email
systems either cannot use HTML or are barred from using it. I bar HTML mail
from my own servers because of several reasons, including the bloated size
of the email, and the ease of putting hidden tags and scripts in the mail,
making it far less secure.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bill said:
This is what I have so far. How/where can I put the tags??:

Private Sub Command125_Click()
'Creates a new e-mail item and modifies its properties.

Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>Enter the message text here. &
Me.[Check-out
Date] </BODY></HTML>"
.Display
End With

End Sub


Arvin Meyer said:
Pass the data as a string in the body of the email:

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

Dim strTo as String
Dim strSubject As String
Dim strBody As String

strTo = Me.txtEmail
strSubject = "This is a sample"
strBody = "Name " & Me.txtName & vbCrLf & _
"Address " & Me.txtAddress & vbCrLf & _
"More data, etc. " & Me.txtWhatever

With objEmail
.To = strTo
.Subject = strSubject
.body = strBody
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
B

Bill

This is a great group. Thank you for all your help. I was able to "wake up"
and realize my error last night with all of your help!

Thank you.


Arvin Meyer said:
However you did it before, is the same way you do now, except using the
objMail object in your code. I do not use HTML mail because many email
systems either cannot use HTML or are barred from using it. I bar HTML mail
from my own servers because of several reasons, including the bloated size
of the email, and the ease of putting hidden tags and scripts in the mail,
making it far less secure.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bill said:
This is what I have so far. How/where can I put the tags??:

Private Sub Command125_Click()
'Creates a new e-mail item and modifies its properties.

Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)

With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = "<HTML><BODY>Enter the message text here. &
Me.[Check-out
Date] </BODY></HTML>"
.Display
End With

End Sub


Arvin Meyer said:
Pass the data as a string in the body of the email:

Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

Dim strTo as String
Dim strSubject As String
Dim strBody As String

strTo = Me.txtEmail
strSubject = "This is a sample"
strBody = "Name " & Me.txtName & vbCrLf & _
"Address " & Me.txtAddress & vbCrLf & _
"More data, etc. " & Me.txtWhatever

With objEmail
.To = strTo
.Subject = strSubject
.body = strBody
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

OK. With help, I was able to get access to send an HTML email. Now I
just
need to get the record to be passed. I know this is probably VERY
simply
but I lost :) Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top