473,594 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTML Emails from Access

Apologies if this has been covered before - I couldn't find it.

I currently use ASPEmail to create and send HTML emails from an Access
database. The text is personalised and includes embedded graphics, eg
logos and even the recipients photo. Note that everything is embedded,
no attachments are sent. ASPEmail works a treat but is very long winded
to create. The email designs come to me as finished HTML but I have to
extract the source and convert it to a string - not that simple a
process - and write quite a bit of code around it to actually get the
thing to work.

What would be nicer would be to do something like I already do for word
documents, that is, set up a template with bookmarks and use automation
to bring up the document, put in the data fields and print it. Is there
something like this I could use with Outlook?

Or does anyone know if there is a better way to do this? I'm happy to
pay for a 3rd party solution.

Thanks
Dave

Jun 9 '06 #1
12 3918
Dave G @ K2 wrote:
Apologies if this has been covered before - I couldn't find it.

I currently use ASPEmail to create and send HTML emails from an Access
database. The text is personalised and includes embedded graphics, eg
logos and even the recipients photo. Note that everything is embedded,
no attachments are sent. ASPEmail works a treat but is very long winded
to create. The email designs come to me as finished HTML but I have to
extract the source and convert it to a string - not that simple a
process - and write quite a bit of code around it to actually get the
thing to work.

What would be nicer would be to do something like I already do for word
documents, that is, set up a template with bookmarks and use automation
to bring up the document, put in the data fields and print it. Is there
something like this I could use with Outlook?

Or does anyone know if there is a better way to do this? I'm happy to
pay for a 3rd party solution.

Thanks
Dave


Consider the code below. If it were to be used extensively it would be
wise to rewrite it using parameters for such things as the html file
path. Probably, an error handler should be included which makes certain
the low-level DOS File is closed, even if some other problem terminates
the execution of the code. (In the olden days, unclosed low-level DOS
files could haunt one's computer for a very long time, causing all
sorts of havoc. I don't know if this is still true.) I expect that you
already know that in HTML E-Mail one may have to use absolute hrefs,
srcs etc in img and other tags etc. Alts are a good idea too.

If the HTML file has distinct placeholders, such a "PlaceHolderOne ",
one can do simple Replaces to make each send unique. I have done this
previously when posting code.

Public Sub VerySimpleSendH TMLMailWithCDOS ample()

Dim iCfg As Object
Dim iMsg As Object

Dim FileNumber As Integer
Dim Buffer As String

FileNumber = FreeFile()
Open "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\FFDBA Backup\index.ht ml" For Binary As #FileNumber
Buffer = String(LOF(File Number), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber

Set iCfg = CreateObject("C DO.Configuratio n")
Set iMsg = CreateObject("C DO.Message")

With iCfg.Fields
..Item("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" )
= 25
..Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") =
"smtp.aim.c om"
..Item("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e")
= 1
..Item("http://schemas.microso ft.com/cdo/configuration/sendusername") =
"eugenevdeb s"
..Item("http://schemas.microso ft.com/cdo/configuration/sendpassword") =
"Sol1dar1ty4Eve r"
..Item("http://schemas.microso ft.com/cdo/configuration/sendemailaddres s")
= "Eugene V Debs <eu*********@ai m.com>"
..Update
End With

With iMsg
..Configuration = iCfg
..HTMLBody = Buffer
..Subject = "Here's Some HTML"
..To = "lf********@cog eco.ca"
..Send
End With

Set iMsg = Nothing
Set iCfg = Nothing

End Sub
****
News clients will introduce extraneous line-feeds in this code.
****
Do I recommend this? I do not! I recommend uploading the HTML file
(personalized or not) to a server and sending a link to that page in
the e-mail. I have code for that too.

Jun 9 '06 #2
Thanks Lyle

But one of my problems is the subject line. Using either your suggested
code, or the system I'm currently using, I need to convert the raw HTML
into a text string, and that's the bit that takes the time because my
client likes designing some pretty long emails loads of tables, font
changes etc etc. I have it all sussed, putting in graphics and
variables and so on, and it works beautifully. I'm just trying to find
a short cut really.

Dave
Lyle Fairfield wrote:
Dave G @ K2 wrote:
Apologies if this has been covered before - I couldn't find it.

I currently use ASPEmail to create and send HTML emails from an Access
database. The text is personalised and includes embedded graphics, eg
logos and even the recipients photo. Note that everything is embedded,
no attachments are sent. ASPEmail works a treat but is very long winded
to create. The email designs come to me as finished HTML but I have to
extract the source and convert it to a string - not that simple a
process - and write quite a bit of code around it to actually get the
thing to work.

What would be nicer would be to do something like I already do for word
documents, that is, set up a template with bookmarks and use automation
to bring up the document, put in the data fields and print it. Is there
something like this I could use with Outlook?

Or does anyone know if there is a better way to do this? I'm happy to
pay for a 3rd party solution.

Thanks
Dave


Consider the code below. If it were to be used extensively it would be
wise to rewrite it using parameters for such things as the html file
path. Probably, an error handler should be included which makes certain
the low-level DOS File is closed, even if some other problem terminates
the execution of the code. (In the olden days, unclosed low-level DOS
files could haunt one's computer for a very long time, causing all
sorts of havoc. I don't know if this is still true.) I expect that you
already know that in HTML E-Mail one may have to use absolute hrefs,
srcs etc in img and other tags etc. Alts are a good idea too.

If the HTML file has distinct placeholders, such a "PlaceHolderOne ",
one can do simple Replaces to make each send unique. I have done this
previously when posting code.

Public Sub VerySimpleSendH TMLMailWithCDOS ample()

Dim iCfg As Object
Dim iMsg As Object

Dim FileNumber As Integer
Dim Buffer As String

FileNumber = FreeFile()
Open "C:\Documen ts and Settings\Lyle Fairfield\My
Documents\FFDBA Backup\index.ht ml" For Binary As #FileNumber
Buffer = String(LOF(File Number), vbNullChar)
Get #FileNumber, , Buffer
Close #FileNumber

Set iCfg = CreateObject("C DO.Configuratio n")
Set iMsg = CreateObject("C DO.Message")

With iCfg.Fields
.Item("http://schemas.microso ft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microso ft.com/cdo/configuration/smtpserverport" )
= 25
.Item("http://schemas.microso ft.com/cdo/configuration/smtpserver") =
"smtp.aim.c om"
.Item("http://schemas.microso ft.com/cdo/configuration/smtpauthenticat e")
= 1
.Item("http://schemas.microso ft.com/cdo/configuration/sendusername") =
"eugenevdeb s"
.Item("http://schemas.microso ft.com/cdo/configuration/sendpassword") =
"Sol1dar1ty4Eve r"
.Item("http://schemas.microso ft.com/cdo/configuration/sendemailaddres s")
= "Eugene V Debs <eu*********@ai m.com>"
.Update
End With

With iMsg
.Configuration = iCfg
.HTMLBody = Buffer
.Subject = "Here's Some HTML"
.To = "lf********@cog eco.ca"
.Send
End With

Set iMsg = Nothing
Set iCfg = Nothing

End Sub
****
News clients will introduce extraneous line-feeds in this code.
****
Do I recommend this? I do not! I recommend uploading the HTML file
(personalized or not) to a server and sending a link to that page in
the e-mail. I have code for that too.


Jun 10 '06 #3
Dave G @ K2 wrote:
Thanks Lyle

But one of my problems is the subject line. Using either your
suggested code, or the system I'm currently using, I need to convert
the raw HTML into a text string, and that's the bit that takes the
time because my client likes designing some pretty long emails loads
of tables, font changes etc etc. I have it all sussed, putting in
graphics and variables and so on, and it works beautifully. I'm just
trying to find a short cut really.


Put the base "template" HTML in a memo
Jun 10 '06 #4
Dave G @ K2 wrote:
Thanks Lyle

But one of my problems is the subject line. Using either your
suggested code, or the system I'm currently using, I need to convert
the raw HTML into a text string, and that's the bit that takes the
time because my client likes designing some pretty long emails loads
of tables, font changes etc etc. I have it all sussed, putting in
graphics and variables and so on, and it works beautifully. I'm just
trying to find a short cut really.


Put the base "template" HTML in a memo field of a table and insert markers into
it. I use things like {Some_Data_Fiel d_Name}. When constructing the EMail just
use several iterations of the Replace() function to insert your real data and
then stuff the result into the Email.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 10 '06 #5
There is no substantive difference between an HTML string and any other
string. We call the one an HTML string because it contains HTML tags;
when this string is sent to a browser, the browser interprets these
tags and shows the results of wonderful tricks the instructions for
which are determined by the tag.
We can save the string as a file, or in a sufficiently large field. We
can retrieve the string and we can send that to an e-mail program. The
only difference between having the e-mail message rendered as HTML and
having it rendered in plain text is the instruction we give to the
e-mail program.
Almost all coding languages have a replace function which can be used
to modify any string, including an HTML string.

Jun 10 '06 #6
"Dave G @ K2" wrote
I need to convert the raw HTML
into a text string, and that's the bit
that takes the time because my
client likes designing some pretty
long emails loads of tables, font
changes etc etc.


Help me understand: I have always been under the impression that "raw HTML"
_IS_ a text string.

Do you mean you need to find just the _content_ and extract it from the
formatting markup as a plain text string?

Larry Linson
Microsoft Access MVP
Jun 10 '06 #7
I'll try to explain - HTML is indeed a text string, but if you look at
a web page, then view source, then copy and paste the source into an
Access module and assign it to a string variable, then the mail program
fails. It fails because you need to take care of all the places where
quote marks are used in normal html

eg html may look like this: <table width="33">
assign that to a text variable s gives
s = "<table width="33">"

but to make it work you need
s = "<table width=""33"">"

Similarly:
s = "<font color=#" & "123456>"

OK, that's not too hard but with a lot of complex html it becomes a
real pain to have to go through it all and make the changes. I'm trying
to find an alternative method as what I'm given is a perfect finished
page of html.

Dave

Larry Linson wrote:
"Dave G @ K2" wrote
> I need to convert the raw HTML
> into a text string, and that's the bit
> that takes the time because my
> client likes designing some pretty
> long emails loads of tables, font
changes etc etc.


Help me understand: I have always been under the impression that "raw HTML"
_IS_ a text string.

Do you mean you need to find just the _content_ and extract it from the
formatting markup as a plain text string?

Larry Linson
Microsoft Access MVP


Jun 14 '06 #8
Dave G @ K2 wrote:
I'll try to explain - HTML is indeed a text string, but if you look at
a web page, then view source, then copy and paste the source into an
Access module and assign it to a string variable, then the mail
program fails. It fails because you need to take care of all the
places where quote marks are used in normal html

eg html may look like this: <table width="33">
assign that to a text variable s gives
s = "<table width="33">"

but to make it work you need
s = "<table width=""33"">"

[snip]

You do not need to do this. I assign long HTML markup to string variables
all the time and I don't have to do anything about the quotes in the HTML.
If you are *building* the string in your code then you do have this issue,
but if you pull the HTML from a file or database record then it is not an
issue. Same is true of long complex SQL strings. If I pull them from a
database field then I don't have to worry about all of the usual quote
delimiting that would be required were I constructing the string inside the
code routine.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 14 '06 #9
Aha !!
I've just realised something - the html source I receive from the
designer has quote marks around every parameter eg <table width="33">.
I now discover that these quote marks are not needed. Apparently they
are good practice, but not essential. So if I get rid of all quote
marks withing the html then my problems are solved. Even better, the
designer is going to strip them all out for me - big sigh of relief.

Dave

Rick Brandt wrote:
Dave G @ K2 wrote:
I'll try to explain - HTML is indeed a text string, but if you look at
a web page, then view source, then copy and paste the source into an
Access module and assign it to a string variable, then the mail
program fails. It fails because you need to take care of all the
places where quote marks are used in normal html

eg html may look like this: <table width="33">
assign that to a text variable s gives
s = "<table width="33">"

but to make it work you need
s = "<table width=""33"">"

[snip]

You do not need to do this. I assign long HTML markup to string variables
all the time and I don't have to do anything about the quotes in the HTML.
If you are *building* the string in your code then you do have this issue,
but if you pull the HTML from a file or database record then it is not an
issue. Same is true of long complex SQL strings. If I pull them from a
database field then I don't have to worry about all of the usual quote
delimiting that would be required were I constructing the string inside the
code routine.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Jun 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2878
by: dan glenn | last post by:
I'm creating HTML emails from a PHP site and sending them out to an email list (just about 40 people so far are on this list). I've tested and confirmed that these emails work in yahoo.com's webmail. And I know they work on *my* Outlook Express. But I have one person (I know of) who gets the emails as plain text, so she sees the HTML code for the email instead of its proper representation. She has, like myself, OE6, and other html emails...
7
2206
by: news | last post by:
Before I begin, I realise there's a big war regarding HTML in e-mails. Personally, I don't like it. Unfortunately, I'm being paid by my company to create an automated newsletter for our customers. I did all I could just to get them to allow me to have it sent in both plaintext and HTML so that the e-mail clients have a choice. Anyway. I've looked around the RFC's and the source of similar e-mails, and I'm certain I figured out how to do...
2
4295
by: Bob | last post by:
Hi Everybody A tough one!!! Is there any way that incoming eMails (MailItems) into Ms Outlook can be used to automatically create records in a ms Access table or sub table. Smiley Bob
3
4749
by: Wizard | last post by:
In Access, using VBA, I am sending emails based on query results. These email include relevant information to a scheduled event the recipient is assigned to. This is working great. What I have been ask to do now is to include an attached file, that when opened will be an Outlook Calendar event and when saved the event will be added to the recipient's calendar in Outlook. These files are .vcs files. I am able to create the necessary...
7
1744
by: Tappy Tibbons | last post by:
We are writing a dotnet app that among other things retrieves messages from a standard POP3 mailbox, and then performs certain actions with that email automatically. Some of the emails are coming in as HTML, which makes the email itself 8 times as large when it comes time to store it, as well as makes it impossible to display to the user using any sort of standard dotnet control. Is there a way to STRIP OUT all the html tags and get...
7
4381
by: Ray Booysen | last post by:
Hi all I'm sending email via ASP.NET in HTML mode. Each email has exactly one attachment and I do have full access to the SMTP server. However, if I send the email in HTML format, the framework reports the following exception: "System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown
21
2721
by: maya | last post by:
hi, I'm designing an HTML email for a client.. I know general guidelines (no CSS, no JavaScript... although I do use limited CSS, inside tags (as in <span style=".."we do this at work and it works fine, so I figured it's ok..) but I have a few more questions, for example, is it ok to do client-side image-maps? is there a web page somewhere with general guidelines for HTML e-mails? (and what is best way to test HTML e-mails? (I...
14
4234
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be something I'm missing header-wise that keeps me from making this work on my work system. I'm using Apache 1.3, PHP 4.1 (best the IT guys could do though I'm using 5.x at home), and MySQL as the database. Thanks VERY much for any help or...
0
3426
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all my emails stored on the Yahoo! server. However sometimes I can’t get access to a PC/the web and I download my emails to a PDA/palmtop via POP3. The PDA uses Windows Mobile software. Since using the PDA, I have had the problem of emails disappearing from the Yahoo! server. However I think I now understand how to avoid this. It seems that Windows Mobile is...
0
7947
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7880
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8010
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3868
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.