Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / June 2005

Tip: Looking for answers? Try searching our database.

How can i insert a record from access into outlook using automati.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
a8player - 08 Apr 2005 15:43 GMT
i am using XP Professionel. In access i have used automation to open an
outlook page (e-mail) In the body of the message i would like to insert a
access record is this possible
Dale - 08 Apr 2005 16:29 GMT
Instead of using automation to open outlook, use the following command
   DoCmd.SendObject acSendNoObject, , acFormatTXT, _
   "To", "CC", "BCC", "Subject", "Message", True
You can change the variables in the quotes to match anything you wish,

Dale

> i am using XP Professionel. In access i have used automation to open an
> outlook page (e-mail) In the body of the message i would like to insert a
> access record is this possible
Neil - 08 Apr 2005 16:37 GMT
If you wish to add the contents of a record, I suggest you have a form open
that has the record you want to use on it, and a command button linked to the
code listed a little later.

For this demo assume the form has four fields called: Fname, LName, DOB, Sex

The contents of your record for the above fields is: John, Smith, 15th June
1967, Male

in the 'on click' event for your button put the following code.

'Takes the contents of the fields and put them into variables.
Firstname = Form.Fname
Lastname = Form.Lname
DateBirth = Form.DOB
MF = Form.Sex

'Build the body of the E-mail
Bodytext = "First Name: " & Firstname +CHR(13)
Bodytext = Bodytext & "Last Name: " & Lastname +CHR(13)
Bodytext = Bodytext & "Date Of Birth: " & DateBirth +CHR(13)
Bodytext = Bodytext & "Sex: " & MF

Dim objOutlook As Object  
Dim objmailItem As Object    
     
'Create the Outlook object
Set objOutlook = CreateObject("Outlook.Application")

'Access a new mail item
Set objmailItem = objOutlook.CreateItem(olmailItem)

'Do things with the E-mail
With objmailItem
.Body = bodytext
.display    'Use .Send if you want the message sent instead of display
End With

Set objmailItem = Nothing
Set objOutlook = Nothing

'End Of Code.....................

What this does is take the contents of the fields, and add them to an Ascii
string called Bodytext.
The code then creates an Outlook object, and using the .body property
inserts the variable Bodytext into the body of the e-mail, creating and Email
looking something like this:

First Name: John
Last Name: Smith
Date Of Birth: 15th June 1967
Sex: Male

All you would need to do is select recipients for the Email, and a subject
line.
These can also be added programatically is you wish using the .to property
and .subject property eg.
.to = "me@myisp.com"
.subject = "This is an E-mail"

There are also properties such as .cc, .bcc, .importance,
.readrecieptrequested. which can all be set programatically if required.

Hope this is all clear enough and helps, if not please post again or contact
me.

Neil
www.nwarwick.co.uk

> i am using XP Professionel. In access i have used automation to open an
> outlook page (e-mail) In the body of the message i would like to insert a
> access record is this possible
jh3016 - 26 Jun 2005 22:11 GMT
This is a VERY HELPFUL post.  Thank you.

Now I have some more questions.
I also have on my form:

TO:
CC:
SUBJECT:

What is the code to add that so that it can populate automatically from my
form?

> If you wish to add the contents of a record, I suggest you have a form open
> that has the record you want to use on it, and a command button linked to the
[quoted text clipped - 69 lines]
> > outlook page (e-mail) In the body of the message i would like to insert a
> > access record is this possible
Neil - 26 Jun 2005 22:39 GMT
The commands you need are .to  .cc and .subject respectively:

e.g. if your E-mail recipient address is in a variable called EmailRecipient
then to add them to the 'To:' box use:

.to = EmailRecipient

The same then applies to .cc and .subject

Note, if you're going to add multiple email adresses then you will also need
to add a semi-colon like this

.to = EmailRecipient  & ";" & EmailRecipient2 & ";" & EmailRecipient3

Hope this helps (If not please post back)

Neil
www.nwarwick.co.uk

> This is a VERY HELPFUL post.  Thank you.
>
[quoted text clipped - 81 lines]
> > > outlook page (e-mail) In the body of the message i would like to insert a
> > > access record is this possible
jh3016 - 26 Jun 2005 22:54 GMT
This worked perfectly, thanks for being patient with me.

Now I want to get fancy.

I want three fields to repeat for each record that the user makes.  
(Probably I'm doing it backwards, but I made three fields:)

txtbody1
txtbody2
txtbody3

In all three fields I put the message, something like:
txtbody1 (this will always be the same for each email)
Welcome to my company.  We want to acknowledge that you have bought the
following products:

txtproducts are listed here

txtbody2 (this will always be the same for each email)
We will be contacting you shortly to confirm this order.
etc.

So I made txtbody1 and txtbody2 NOT visible.  When the user goes to click
another record, I want txtbody1 and txtbody2 to always be there with the
pre-determined text (that they cannot edit on the form).

Can you tell me how to do this?

> The commands you need are .to  .cc and .subject respectively:
>
[quoted text clipped - 100 lines]
> > > > outlook page (e-mail) In the body of the message i would like to insert a
> > > > access record is this possible
David C. Holley - 27 Jun 2005 01:05 GMT
Sounds like you just need to create a string-type variable with the text
and then concatanate(sp) them for the message body.

strMessageHeader = "Thank you for shopping at MegaMart."
strMessageFooter = "Please pay your bill promptly to ensure that your
first born is not taken as payment."

Then
.Body* = strMessageHeader & "Here are your products" & strMessageFooter
*or correct property to set the message text - I'm always looking it up

which results in ...

Thank you for shopping at MegaMart.Here are your products.Please pay...

> This worked perfectly, thanks for being patient with me.
>
[quoted text clipped - 128 lines]
>>>>>outlook page (e-mail) In the body of the message i would like to insert a
>>>>>access record is this possible
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.