473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Table-to-email using SELECT INTO OUTFILE

JamieHowarth0
533 Expert 512MB
Hi folks,

Got a problem - I've got all my automated emails (in HTML format) stored in a table in my DB (called tbl_emails). I've set up a trigger so that every time a new user registers (data put into tbl_users), it creates a validation code using UUID(), and outputs an email into my mail pickup folder (idea being that if the user clicks on the link contained in the email, they get validated).
Code looks like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT CONCAT("To: ",NEW.CltEmail),
  2. "From: myemail@cmdev-associates.com",
  3. "Subject: New User Registration", "",
  4. REPLACE(
  5. REPLACE(
  6. REPLACE(tbl_emails.EmailContent,'{0}',NEW.CltEmail)
  7. ,'{1}',NEW.FName)
  8. ,'{2}',NEW.EmlCode)
  9. INTO OUTFILE "//mymailpickup//email.eml"
  10. FROM tbl_ocemails WHERE EmailID = 1
  11. FIELDS TERMINATED BY "\b\n";
  12.  
My problem is that the email contents are meant to be HTML but I'm testing it by registering myself and I'm only receiving the HTML code in plain-text - entirely unformatted. Not only that but I'm getting double slashes (\ \) at the end of every line break in the email content. What am I missing here?

Many thanks in advance,

medicineworker
Sep 23 '07 #1
8 3717
pbmods
5,821 Expert 4TB
Heya, medicineworker.

To send HTML emails, you need to set the Content-type header for your email. See this page for more information.

The '\ \' that you're seeing is probably an escaped "\r\n".
Sep 23 '07 #2
JamieHowarth0
533 Expert 512MB
Hi pbmods,

Thanks for that, I found the Content-Type header tip (and MIME-Version) thru Google and added that as an extra field, but now I'm hitting a new stumbling block - the email message itself is completely blank (with the exception of "no virus found" put there by my anti-virus)! Any more ideas?

Many thanks

medicineworker
Sep 24 '07 #3
pbmods
5,821 Expert 4TB
Heya, Medicineworker.

Can you view the .eml file directly? Is your MySQL query generating an error?
Sep 24 '07 #4
JamieHowarth0
533 Expert 512MB
Hi pbmods,

Found the solution to part of my problem - forgot to put a blank line between email headers and the actual content, so the email is now arriving as an HTML email (to an extent).
I'm still getting backslashes at each line though (which I'm guessing is a problem to do with FIELDS TERMINATED BY)?

Problem is now 99% fixed though, which is better than nothing!

Many thanks,

Benjamin

P.S. MySQL trigger doesn't generate any errors - but have had bad mail pickups previously when it hasn't outputted the data in the intended fashion (all working error-free now, with the exception of the dreaded \).
Sep 24 '07 #5
JamieHowarth0
533 Expert 512MB
Hi pbmods,

And the problem is finally solved! FIELDS TERMINATED BY "\b\n" ESCAPED BY "\\" is the MySQL default - so I removed the escape characters ("\\") and it works a dream!

Thanks for your help,

medicineworker
Sep 24 '07 #6
pbmods
5,821 Expert 4TB
Heya, medicineworker.

Interesting. Thanks for posting the solution.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 24 '07 #7
Hi pbmods and medicine worker,
Thanks for working thru this thread. It has given me a start in figuring out how to send HTML emails. Thanks again.
Sep 25 '07 #8
JamieHowarth0
533 Expert 512MB
Hi BenMore,

If you do need any help, or just want to take a look at the code I've sussed out so far, then drop me a PM/email and I'll send you the triggers and code I'm currently using.

medicineworker
Sep 25 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marco | last post by:
Hello there ;) I'm trying to build a scrip that would open a page that has a table and then get all the values as variables so I can put them in a MySQL DB. The problem is that I don't really...
14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
2
by: David Bradbury | last post by:
I currently have an iframe on a webpage into which users can insert content. They can further customise the text as I've included buttons such as Bold, Italic, Bullet point etc. This is done along...
3
by: Werner Eggert | last post by:
Hello, i have a frameset with 3 rows. The top row of the frame has a table (height: 50px). This table should be aligned on bottom of the Top-Frame (height: 100px). The problem: at the moment the...
2
by: Andy Flash | last post by:
Hi. I'd like a little help working out what is going on with what should be a simple alignment problem. I have an outer table with a <td> which has an inner table. The <td> specified as...
7
by: ALI-R | last post by:
Hi All, I have two user controls (header and footer) ,,which I've placed in an HTML Table in a page.I set the **align="center"** in the table and the table still is on the left side of the page...
6
by: Sundew Shin | last post by:
I think I can make a good interesting list of postings under this subject header, 'All browsers are cool but IE.' Anyway, the following code will show a table with an input box labeled, 'name',...
2
by: Albin | last post by:
Hi, I have a html page where in the table spans for two pages the first page's last row doesn end properly and the 2nd page's first row also isnt proper.The code i use is given below,the no of...
12
by: Michael.Z | last post by:
Anyone who can help: Given a Table.h file I am writing a Table.c file. I keep getting the compile error: previous declaration of Table was here / conflicting types for I think the...
0
by: RubbedLung | last post by:
http://www.hometeamproperties.net/Forms/PVA/LPV.htm As you can see its a valid page but now the bottom right rounded corner is gone, and there are entire blocks of color missing from the interior...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.