944,020 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 3849
  • ASP RSS
Oct 22nd, 2006
0

Ecard:MHTML -v- linked HTML

Expand Post »
Dear All,
This is my first post - I was delighted to stumble across such a great resource.

I am trying to set up a simple e-card system for my website using HTML formatted CDOSYS email messages. At present I have the system up and running in a raw form by sending a pre-designed webpage (containing the image/card and a link back to my site) using MHTML. Here is my current code for the CODSYS page:

ASP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <body>
  4. <%
  5. SMTPServer = "server.mysite.com"
  6. cdoURL = "http://schemas.microsoft.com/cdo/configuration/"
  7.  
  8. MHTMLBody = "http://www.mysite.com/ecard/image1.asp"
  9.  
  10. Set cdoM = CreateObject("CDO.Message")
  11. Set cdoC = CreateObject("CDO.Configuration")
  12. Set cdoF = cdoC.Fields
  13.  
  14. With cdoF
  15. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  16. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
  17. .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
  18. .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  19. .Update
  20. End With
  21.  
  22. With cdoM
  23. Set .Configuration = cdoC
  24.  
  25. .CreateMHTMLBody MHTMLBody
  26. .From = Request("sender")
  27. .To = Request("receiver")
  28. .Subject = Request("subject")
  29. .TextBody = Request("body")
  30. .Send
  31. End With
  32.  
  33. Set cdoM = Nothing
  34. Set cdoS = Nothing
  35. Set cdoF = Nothing
  36. %>
  37.  
  38.  
  39.  
  40.  
  41. Your ecard has been sent. Thank you!
  42. </body>
  43. </html>

This works fine but, because it is MHTML, the size of the email is quite large as the image etc. is actually sent to the recipient's inbox rather than linking back to the file on my server.

I have searched this and other forums and a few threads point to another method which seems to link the HTML rather than send it as MHTML (eg. http://forums.aspfree.com/asp-develo...ght=HTML+email) .

Unfortunately my NEWBIE understanding of ASP prevents me from applying this method to my own scenario. As far as I can make out I have to set the "HTMLBody Option" (how?) and then use some form of variable (eg strHTML = strHTML & "<HTML>"???). As I said however, I don't know exactly how to do this and each version I see appears to be different.

Ideally the recipient of the e-card would see the image in the email with a short HTML-formatted message from the sender. This now works for my MHTML method but each email is over 40kb in size which is unfair to the recipient who may not desire the ecard. I would like if the email size was under 10kb by linkind to the HTML.

Using MHTML means I have to have a pre-designed page for every card - it looks like this other way is more flexible and I could load in a "response.write(request.form("image_name.jpg"))" clause in the relevant section since the rest of the page layout will be identical. This would make maintenance much easier. Maybe not possible?

Any pearls of wisdom would be hugely appreciated. I am only beginning in this ASP undiscovered country but am very excited by it already!!!

Many thanks
-eogmp3
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eogmp3 is offline Offline
3 posts
since Oct 2006
Oct 22nd, 2006
0

Re: Ecard:MHTML -v- linked HTML

Hi again. I've been messing around here and think i'm getting somewhere. Unfortunately I can't access the actual server that I'll be using at present (I will tomorrow at work) and I can't seem to get my localhost to process CDOSYS (browser gives the following error :Error Type:CDO.Message.1 (0x80070005). Access is denied. /ecard/html4.asp, line 25). This means that I can't really test out what i'm doing.

Can someone tell me if I'm on the right track with this code:
ASP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <body>
  4. <%
  5. dim MyMail, strHtmlBody
  6.  
  7. SMTPServer = "localhost"
  8. cdoURL = "http://schemas.microsoft.com/cdo/configuration/"
  9.  
  10. Set MyMail = CreateObject("CDO.Message")
  11.  
  12. Set cdoC = CreateObject("CDO.Configuration")
  13. Set cdoF = cdoC.Fields
  14.  
  15. With cdoF
  16. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  17. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
  18. .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
  19. .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  20. .Update
  21. End With
  22.  
  23. strHtmlBody = strHtmlBody & "<HTML>"
  24. strHtmlBody = strHtmlBody & "<p align="center"> Hello <% response.write(request.form("rName"))%>, <% response.write(request.form("sName"))%> has sent you this ecard:"
  25. strHtmlBody = strHtmlBody & "<img src=""http://www.mysite.com/images/ecard1.jpg""></p>"
  26. strHtmlBody = strHtmlBody & "<b>Message:</b><% response.write(request.form("body"))%>"
  27. strHtmlBody = strHtmlBody & "<p><a href=""http://www.mysite.com/ecard.asp"">click here</a> to send your own ecard."
  28. strHtmlBody = strHtmlBody & "<p>Thank you</p>"
  29.  
  30. With MyMail
  31. Set .Configuration = cdoC
  32.  
  33. .From = Request("sAddress")
  34. .To = Request("rAddress")
  35. .Subject = "Test"
  36. .HTMLBody = strHtmlBody
  37. .Send
  38. End With
  39.  
  40. Set MyMail = Nothing
  41. Set cdoS = Nothing
  42. Set cdoF = Nothing
  43. %>
  44.  
  45.  
  46.  
  47.  
  48. Your ecard has been sent. Thank you!
  49. </body>
  50. </html>
Much appreciated.
-eogmp3
Last edited by eogmp3; Oct 22nd, 2006 at 2:45 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eogmp3 is offline Offline
3 posts
since Oct 2006
Oct 22nd, 2006
0

Re: Ecard:MHTML -v- linked HTML

Well I'm off to bed now. Hopefully I'll be able to check the above script on a working server tomorrow. I'll check back in then...
Thanks
-eogmp3
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eogmp3 is offline Offline
3 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Asp applications
Next Thread in ASP Forum Timeline: Update Column Serial Wise





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC