Saturday, May 21, 2005

Insert Picture into Email

How to insert picture in email body when using CFMAIL ?

First, you must be running MX6.1 with updater installed or MX7.

When using inline images inside an email, you need to use a Content ID to reference it instead of the file name. This Content ID needs to be globally unique - meaning that there should never be a duplicate Content ID used, ever. To assist in this, you can use a CID function I wrote to create such a value.

function CID()
{
return LCase(CreateUUID() & "@" & FormatBaseN(RandRange(0,65535),16) &
"@" & ListFirst(CGI.Server_Name,"."));
}

Okay, now let's assign a Content ID to an image. You would do these same steps for every image. Code references in this email assumes a <cfscript> block except for the cfmail tag.

CFSET ImgLogo=CID();

Now you want to create your HTML. When referencing the image, reference the CID value with a "cid:" prefix. Keep in mind that using two double-quotes escapes it so you can embed quotes inside variables instead of using Chr(34). Another option of generating your email body is to simply generate it normally as HTML but with a cfsavecontent tag wrapped around it so any generated HTML will be stored in a variable instead of being sent to the browser.

EmailBody="<html><body><img src=""cid:#ImgLogo#""></body></html>";

Now using the cfsavecontent tag.
<cfsavecontent variable="EmailBody">
<html><body>
<img src="cid:#ImgLogo#">
</body></html>
</cfsavecontent>

Now we're ready to execute our CFMAIL tag.

<cfmail to="foo@bar.com" from="foo@bar.com" subject="Test" type="HTML">
#EmailBody#
<cfmailparam file="RootDir#/logo.gif" type="image/jpeg" contentid="#ImgLogo#" disposition="attachment">
</cfmail>

I found that it's best to include the images at the end of the email body, otherwise MX will add extra line feeds at the top unless you put everything in one big long line

Friday, May 20, 2005

I Need An Auto Email Responder In Coldfusion

I am developing a email-based friends network management project with Coldfusion. I am sending periodic emails to the members according to particular time or date. So I need some kind of periodically executing code snippet.

Here you go:

<cfquery name="qryUsers" datasource="#DSN#">
SELECT *
FROM Users
WHERE datefield IS BETWEEN '2005-06-10' AND '2005-06-11'
</cfquery>

<cfloop query="qryUsers">
<cfmail to="#qryUsers.email#" bcc="youremail@yourhost.com" server="mail.yourhost.com" from="youremail@yourhost.com" subject="Email Subject" type="HTML">
<pre>
Hello #Fname# #Lname#,

How are you today?
</pre>
</cfmail>
</cfloop>

Thursday, May 19, 2005

Deleting A Character Using replace()

I am having a problem replacing a string occurance with "". In efect I want to remove chr(13) characters from a string but the below code gives the error: Argument 2 of function Replace cannot be an empty value.

My Code: var sStringNew = replace(pMemoString,"",chr(13),"ALL");

Arguments 2 and 3 are transposed. The search string comes first, then the replacement string.
var sStringNew = replace(pMemoString,Chr(13),"","ALL")

Also, if you're looking to just strip out Chr(13), you can use the StripCR function.
<cfset sStringNew=StripCR(pMemoString)>

Wednesday, May 18, 2005

Photoshop - Help With Changing Colors

I have an image which I want to use as a background on an invitation, to be printed on translucent paper. The image is black and white (well, grey-ish actually) and we want to change the whole of the image to be in blue tones instead of grey.

Here you go:

File > Open
Image > Mode (make sure it RGB is ticked)
Image > Adjustments > Hue and Saturation > check Colorize

Then play with the sliders until you get what you want.

Tuesday, May 17, 2005

Really Nice Web Site

This is a really nice site and it has a great Javascript menu

(Go Here and click the "Click to watch")

Monday, May 16, 2005

Clickable US Map

Where can I find a clickable US map?

backspace.com

or

town-usa.com to see exactly what you are talking about in action and then refer to htmlcodetutorial
which will basicly tell you how it works.

Both are pretty self-explanitory once you're on the sites.

Sunday, May 15, 2005

Stupid Question...

Can anyone help me start learning Adobe PhotoShop?

Can anyone help me to find some tutorials to get me started?

Answer:
1. Go to Google
2. Type in "PhotoShop tutorial"
3. Look at all the pages where you can get help.
4. Follow tutorials.