A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Populate message area wtih data fron Access database



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 24th 08, 01:37 PM posted to microsoft.public.outlook.program_vba
LenJr
external usenet poster
 
Posts: 5
Default Populate message area wtih data fron Access database

I am trying to buid a macro(VBA) that reads an MS Access table(Query) and
pulls in the record set into the message area of an e-mail to be sent. This
is will save the analyst time by building the data part of the message
instead of cutting and pasting the info in from a Table or restult query.
Any help would be greatly appreciated.

Thanks!

Ads
  #2  
Old July 24th 08, 11:01 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Populate message area wtih data fron Access database



Please show what you have so far and tell us what the problem is.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 24 Jul 2008 04:37:01 -0700 schrieb LenJr:

I am trying to buid a macro(VBA) that reads an MS Access table(Query) and
pulls in the record set into the message area of an e-mail to be sent.

This
is will save the analyst time by building the data part of the message
instead of cutting and pasting the info in from a Table or restult query.
Any help would be greatly appreciated.

Thanks!

  #3  
Old July 28th 08, 01:14 PM posted to microsoft.public.outlook.program_vba
LenJr
external usenet poster
 
Posts: 5
Default Populate message area wtih data fron Access database

I think I am all set. I was having trouble connecting to my Access 2007 db.
I am new to 2007, have been using 2003. I used this and it seems to work
fine:
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Weather.accdb;Persist Security Info=False;"
Set oDataBase = New ADODB.Connection
oDataBase.Open strConn

Then I was not sure what route to go when populating the message with data.
I was thinking a form but the Analyst needs to be able to free form their
e-mails so I just wanted to populate the message area. Was not sure on how
to populate the data in a table format so I went with the HTML tags. So I
query the data, create record sets and then read thru...for example:
With rstWOY
.MoveFirst

'Create table headings
txtWOY = "trtdCity/tdtdHigh/tdtdLow/tdtdLow
RH%/tdtdNormal High/tdtdNormal Low/tdtdDescription of
Clouds/Significant WX/td/tr"
' Loop through the Microsoft Access records.
Do While Not .EOF
txtWOY = txtWOY & "trtd" & rstWOY!City & "/tdtd" &
rstWOY!High & "/tdtd" & rstWOY!Low _
& "/tdtd" & rstWOY!LowRH & "/tdtd" &
rstWOY!NormalHigh & "/tdtd" & rstWOY!NormalLow _
& "/tdtd" & rstWOY!DescriptionClouds & "/td/tr"
.MoveNext
Loop
End With

Then I put the message together:

Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem

Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)

With olMsg
.To = "email address"
.CC = "e-mail address"
.Subject = "Subject" & Date & "...FINAL"
.HTMLBody = "h2uHeading/u/h2pYesterday's Forecast/p" _
& "table border='0' cellspacing='5'Font color='red'" _
& txtWFY & "/table/fontbrpWeather Observed
Yesterday/p" _
& "table border='0' cellspacing='5'Font color='red'" &
txtWOY _
& "/table/fontbrpWeather Forecast Today/p"

.Display

End With

Set olMsg = Nothing
Set olApp = Nothing



If you know of a better way please let me know....but that is the path I
took and it seems to work well.

Thanks!



"Michael Bauer [MVP - Outlook]" wrote:



Please show what you have so far and tell us what the problem is.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 24 Jul 2008 04:37:01 -0700 schrieb LenJr:

I am trying to buid a macro(VBA) that reads an MS Access table(Query) and
pulls in the record set into the message area of an e-mail to be sent.

This
is will save the analyst time by building the data part of the message
instead of cutting and pasting the info in from a Table or restult query.
Any help would be greatly appreciated.

Thanks!


  #4  
Old July 29th 08, 09:15 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Populate message area wtih data fron Access database



I'd follow the old saying: Never touch a running system.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Mon, 28 Jul 2008 04:14:00 -0700 schrieb LenJr:

I think I am all set. I was having trouble connecting to my Access 2007

db.
I am new to 2007, have been using 2003. I used this and it seems to work
fine:
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Weather.accdb;Persist Security Info=False;"
Set oDataBase = New ADODB.Connection
oDataBase.Open strConn

Then I was not sure what route to go when populating the message with

data.
I was thinking a form but the Analyst needs to be able to free form their
e-mails so I just wanted to populate the message area. Was not sure on

how
to populate the data in a table format so I went with the HTML tags. So I
query the data, create record sets and then read thru...for example:
With rstWOY
.MoveFirst

'Create table headings
txtWOY = "trtdCity/tdtdHigh/tdtdLow/tdtdLow
RH%/tdtdNormal High/tdtdNormal Low/tdtdDescription of
Clouds/Significant WX/td/tr"
' Loop through the Microsoft Access records.
Do While Not .EOF
txtWOY = txtWOY & "trtd" & rstWOY!City & "/tdtd" &
rstWOY!High & "/tdtd" & rstWOY!Low _
& "/tdtd" & rstWOY!LowRH & "/tdtd" &
rstWOY!NormalHigh & "/tdtd" & rstWOY!NormalLow _
& "/tdtd" & rstWOY!DescriptionClouds & "/td/tr"
.MoveNext
Loop
End With

Then I put the message together:

Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem

Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)

With olMsg
.To = "email address"
.CC = "e-mail address"
.Subject = "Subject" & Date & "...FINAL"
.HTMLBody = "h2uHeading/u/h2pYesterday's Forecast/p" _
& "table border='0' cellspacing='5'Font color='red'" _
& txtWFY & "/table/fontbrpWeather Observed
Yesterday/p" _
& "table border='0' cellspacing='5'Font color='red'" &
txtWOY _
& "/table/fontbrpWeather Forecast Today/p"

.Display

End With

Set olMsg = Nothing
Set olApp = Nothing



If you know of a better way please let me know....but that is the path I
took and it seems to work well.

Thanks!



"Michael Bauer [MVP - Outlook]" wrote:



Please show what you have so far and tell us what the problem is.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 24 Jul 2008 04:37:01 -0700 schrieb LenJr:

I am trying to buid a macro(VBA) that reads an MS Access table(Query)

and
pulls in the record set into the message area of an e-mail to be sent.

This
is will save the analyst time by building the data part of the message
instead of cutting and pasting the info in from a Table or restult

query.
Any help would be greatly appreciated.

Thanks!


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Access Table with Email Data & Save attchment as pdf or t Gavski Outlook and VBA 1 October 5th 07 06:44 AM
UserForm Listbox with Access Database Table data RobLo Outlook - Using Forms 4 March 9th 07 04:47 PM
Using data in Access database in outlook forms Weatherman Outlook and VBA 6 April 20th 06 01:46 AM
getting data from Access Database in Outlook Form Weatherman Outlook - Calandaring 1 April 17th 06 02:49 PM
Can custom form data populate access database jbtempe Outlook - Using Forms 1 January 20th 06 04:02 PM


All times are GMT +1. The time now is 09:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.