I am using FCKEditor and CKFinder to create content for HTML email messages. I have it all working fine except the URL for the image contained in the email message. The URL turns out as a relative path rather than the full URL. I need the full URL for the image so it will be displayed properly what is the best way to handle this?
Mon, 10/20/2008 - 20:22
#1
Re: Images in HTML email
Any help would be greatly appreciated.
Re: Images in HTML email
The default configuration in CKFinder points CKFinder to the relative path:
however, you can change it to fully qualified URL:
The only thing that you have to remember about in such scenario is to set also the baseDir variable, e.g.:
because the default value will not work out (config.baseDir = APPLICATION.CreateCFC("Utils.FileSystem").resolveUrl(config.baseUrl);).
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Images in HTML email
Wictor,
Thank you so much for responding.
Based on your suggestion I made the following changes to config.cfm:
config.baseUrl = "http://www.greatesthomebusiness.com/images_email/";
config.baseDir = "c:/websites/ghb/greatesthomebusiness/images_email/";
This worked but created a new problem...
When I browse the server for images CKfinder displays all the thumbnail images as red question marks rather than the image itself.
This worked fine before I made the changes but doesn't now.
What am I missing.
Thank you,
Roger
Re: Images in HTML email
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Images in HTML email
Sorry, but this is a bit confusing to me.
The only two lines of code I changed are the two that I have documented for you.
I have not knowingly changed the thumbnails path. It was working before I made these changes so it must be writable.
Where is the path to the thumbnails set? It is within the CKfinder folder I take it but which file and what line of code am I looking for?
Roger
Re: Images in HTML email
so in your case, if thumbnails stopped working, adjust the config.thumbnails.url and config.thumbnails.baseDir variables (for example instead of using config.baseUrl and config.baseDir helper variables, just use the old working values).
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Images in HTML email
After changing the baseURL and baseDir to the actual URL and directory path everything worked fine.
Thanks for your help,
Roger
Re: Images in HTML email
When it comes to newsmail its much better to embed all the pictures in teh mail so the user never gets those red crosses caus of security issues. I am using the editor for newsmails as well, but i embed the images in the mail. See code example below (In C#.Net):
public void SendHtml(string fromemail, string toemail, string subject, string html)
{
Regex regX = new Regex("src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?", RegexOptions.IgnoreCase);
MatchCollection srcData = regX.Matches(html);
string[] fileNames = new string[srcData.Count];
string[] filePaths = new string[srcData.Count];
int index = 0;
string htmlFinal = html;
foreach (Match match in srcData)
{
string[] sTmp = match.Value.Split('/');
fileNames[index] = sTmp[sTmp.Length - 1];
string pathTmp = "/";
for (int i = 1; i < sTmp.Length-1; i++)
{
pathTmp += sTmp[i] + "/";
}
filePaths[index] = pathTmp;
pathTmp = "/";
index++;
}
string htmlTmp = html;
for (int i = 0; i < fileNames.Length; i++)
{
htmlFinal = htmlTmp.Replace(srcData[i].ToString(), "src=cid:" + fileNames[i].Substring(0, fileNames[i].IndexOf('.')));
htmlTmp = htmlFinal;
}
//htmlFinal += "<p align='left' style='font-size:12px;'><a href='http://adpnews/?rnmr=" + Server.UrlEncode(Encryption.Encrypt(toemail)) + "'>Click here to cancel newsmail subscription</a></p>";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlFinal, null, "text/html");
for(int i=0;i<srcData.Count;i++)
{
string imgLoc = Server.MapPath(filePaths[i]);
LinkedResource logo = new LinkedResource(imgLoc + fileNames[i].Substring(0, fileNames[i].IndexOf('\'')));
logo.ContentId = fileNames[i].Substring(0, fileNames[i].IndexOf('.'));
htmlView.LinkedResources.Add(logo);
}
MailMessage msg = new MailMessage(fromemail, toemail);
msg.Subject = subject;
msg.AlternateViews.Add(htmlView);
msg.IsBodyHtml = true;
SmtpClient mySmtp = new System.Net.Mail.SmtpClient("localhost");
try
{
mySmtp.Send(msg);
}
catch
{
}
}
Re: Images in HTML email
Thanks.
Re: Images in HTML email
In Config.cfm I changed
Config.FileTypesPath["Image"] = Config.UserFilesPath & 'image/' ;
To
Config.FileTypesPath["Image"] = "http://www.mydomain.com" & Config.UserFilesPath & 'image/' ;
And seems to be working fine. Did the same for files and flash.