1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Ecard:MHTML -v- linked HTML

Discussion in 'C#' started by eogmp3, Oct 22, 2006.

  1. #1
    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:

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <% 
        SMTPServer = "server.mysite.com"  
        cdoURL = "http://schemas.microsoft.com/cdo/configuration/"  
      
        MHTMLBody = "http://www.mysite.com/ecard/image1.asp" 
     
        Set cdoM = CreateObject("CDO.Message")  
        Set cdoC = CreateObject("CDO.Configuration")  
        Set cdoF = cdoC.Fields  
     
        With cdoF  
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False  
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60  
            .Update  
        End With  
     
        With cdoM  
            Set .Configuration = cdoC  
             
            .CreateMHTMLBody MHTMLBody 
            .From = Request("sender")  
            .To = Request("receiver")  
            .Subject = Request("subject")  
            .TextBody = Request("body") 
            .Send  
        End With  
     
        Set cdoM = Nothing  
        Set cdoS = Nothing  
        Set cdoF = Nothing  
    %>
    
    
    
    
    Your ecard has been sent. Thank you!
    </body>
    </html>
    Code (markup):
    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 forum and a few threads point to another method which seems to link the HTML rather than send it as MHTML.

    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
     
    eogmp3, Oct 22, 2006 IP
  2. eogmp3

    eogmp3 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <% 
    	dim MyMail, strHtmlBody
    
        SMTPServer = "localhost"  
        cdoURL = "http://schemas.microsoft.com/cdo/configuration/"  
           
        Set MyMail = CreateObject("CDO.Message") 
    	 
        Set cdoC = CreateObject("CDO.Configuration")  
        Set cdoF = cdoC.Fields  
     
        With cdoF  
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2  
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False  
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60  
            .Update  
        End With  
     
    strHtmlBody = strHtmlBody & "<HTML>"
    strHtmlBody = strHtmlBody & "<p align="center"> Hello <% response.write(request.form("rName"))%>, <% response.write(request.form("sName"))%> has sent you this ecard:"
    strHtmlBody = strHtmlBody & "<img src=""http://www.mysite.com/images/ecard1.jpg"></p>""
    strHtmlBody = strHtmlBody & "<b>Message:</b><% response.write(request.form("body"))%>"
    strHtmlBody = strHtmlBody & "<p><a href=""http://www.mysite.com/ecard.asp">click here</a> to send your own ecard.""
    strHtmlBody = strHtmlBody & "<p>Thank you</p>"
     
        With MyMail 
            Set .Configuration = cdoC  
                    
            .From = Request("sAddress")  
            .To = Request("rAddress")   
            .Subject = "Test"
            .HTMLBody = strHtmlBody 
            .Send  
        End With  
     
        Set MyMail = Nothing  
        Set cdoS = Nothing  
        Set cdoF = Nothing  
    %>
    
    
    
    
    Your ecard has been sent. Thank you!
    </body>
    </html>
    
    Code (markup):
    Much appreciated.
    -eogmp3
     
    eogmp3, Oct 22, 2006 IP
  3. eogmp3

    eogmp3 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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
     
    eogmp3, Oct 22, 2006 IP