Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2006, 07:41 PM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASPMail embaded images

Hi,
  I am having problem with one of my application which sends mails using ASP Mail. My application is an internal web application which sends out mails to customers outside network. With the mail it sends an image of logo as an url to the internal web folder which fails to show up to the receipent out side the company network. So I tried to use attachurl method of ASP Mail but it is not supported. So I tryed to send multipart message using mime format. I was able to send multi part mail using text and html. But the message with text and jpg is not working. It will be very helpful if you can give me solution of this problem.

Regards,

Kalpit
 
Old January 9th, 2006, 01:06 PM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi here is the code of the file which is not working
<%
Function base64_encode_fromfile( byval sFilename )
    Dim objXMLDoc, objDocElem, objStream, sBase64String
    Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
        objXMLDoc.async = False
        objXMLDoc.validateOnParse = False
    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Type = 1
    objStream.Open
    objStream.LoadFromFile Server.MapPath(sFilename)
    'Set objDocElem = objXMLDoc.documentElement
    Set objDocElem = objXMLDoc.createElement("A")
    objDocElem.dataType = "bin.base64"
    objDocElem.nodeTypedValue = objStream.Read
    sBase64String = objDocElem.text
    objStream.Close
    Set objStream = Nothing
    Set objDocElem = Nothing
    Set objXMLDoc = Nothing
    base64_encode_fromfile = sBase64String
End Function

  ' ****************************************
  ' * DO NOT MODIFY THE FOLLOWING VALUES *
  ' * ServerObjects Inc. will NOT debug *
  ' * multi-part message problems! *
  ' * DO NOT MODIFY THE FOLLOWING VALUES *
  ' ****************************************
  BOUNDARY = "----xxxxxx"
  TEXT_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: image/jpeg;" & VBCrLf & _
                "Content-Transfer-Encoding: 64bit;" & VBCrLf & _
              "Content-ID: ZendImage12345" & VBCrLf & VBCrLf
  'TEXT_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: text/plain;" & VBCrLf & _
  ' "Content-Transfer-Encoding: 7bit" & VBCrLf & VBCrLf
  HTML_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: text/html;" & VBCrLf & _
                "Content-Transfer-Encoding: 7bit" & VBCrLf & VBCrLf
  MP_FOOTER = "--" & BOUNDARY & "--" & VBCrLf


  ' ************************************************** ****
  ' * Set strTextBody to your message in plain text format
  ' ************************************************** ****
  strTextBody = base64_encode_fromfile("logo.jpg")
   ' ************************************************** ****
  ' * Set strHTMLBody to your message in HTML format
  ' ************************************************** ****
  strHTMLBody = "This is the company logo:<IMG SRC=""cid:ZendImage12345"">"


  ' ****************************************
  ' * DO NOT MODIFY THE FOLLOWING VALUE *
  ' ****************************************
  strBody = HTML_HEADER & strHTMLBody & VBCrLf & TEXT_HEADER & strTextBody & VBCrLf & MP_FOOTER


  ' ****************************************
  ' * Code your Mailer Object creation and
  ' * setup here
  ' ****************************************
  Set Mailer = Server.CreateObject ("smtpsvg.mailer")
  Mailer.RemoteHost = "mymailserver.com"
  Mailer.AddRecipient "Kalpit", "[email protected]"
  Mailer.FromName = "Bala"
  Mailer.FromAddress = "[email protected]"
  Mailer.Subject = "MultiPart Message"

  ' ****************************************
  ' * DO NOT MODIFY THE FOLLOWING VALUES *
  ' ****************************************
  Mailer.ContentType = "multipart/alternative; boundary=""" & BOUNDARY & """"
  Mailer.BodyText = strBody


  ' ****************************************
  ' * Send the message
  ' * Code your testing for the success of
  ' * SendMail here
  ' ****************************************
  if Mailer.SendMail then
    Response.Write ("<br>Mail sent OK<br>")
    Response.Write (strBody)
  else
    Response.Write ("<br>Mail failed. Error was " & Mailer.Response)
  end if

  Set Mailer = Nothing

%>





Similar Threads
Thread Thread Starter Forum Replies Last Post
aspMail Morn Classic ASP Basics 3 February 26th, 2007 06:51 PM
aspMail Morn ASP.NET 2.0 Basics 1 February 25th, 2007 09:40 PM
ASpMail chocobabe100 Classic ASP Basics 1 May 5th, 2005 11:27 PM
ASPMail / Shift_JIS jz552 Classic ASP Professional 0 May 4th, 2005 02:39 PM
AspMail mmarkym Classic ASP Components 2 December 21st, 2003 01:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.