Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components 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 February 25th, 2004, 03:41 PM
Authorized User
 
Join Date: Feb 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default EMail (CDONTS) File Attachment is blank

Hi there,

Client receiving EMail(used CDONTS) with File Attachment which appears blank. The E_Mail, with file, opens for some users but not others.

When, the client opens the E_Mail with attachment, using Hotmail the file is blank. The downloading dialogue box is not triggered. When the client opens the E_Mail with attachement, using MSOutlook (but not a Hotmail account), the file opens fine.

Other than this issue, our server scripting appears to be working fine, all E_Mails are successfully sent with attachments.

When the E_Mail, with file, is sent directly from my E_Mail tool (MSOutlook, via the same provider) the file can be opened in Hotmail.

Do you suspect a Server setting or an ASP coding issue?

Here is the code:
 function sendmail(recipient_address, sender_address, subject, body, attachment)
    Dim objMail, n, n0
    on error resume next
    set objMail = CreateObject("CDONTS.NewMail")
    objMail.From = sender_address
    objMail.To = recipient_address
    objMail.Subject = subject
    objMail.Body = body
    if trim(attachment) > "" then
        n = InStr(1,attachment,",")
        if n = 0 then
            objMail.AttachFile(trim(attachment))
        else
            n0 = 0
            Do while n > 0
                objMail.AttachFile(trim(Mid(attachment,n0+1,n-n0-1)))
                n0 = n
                n = InStr(n0+1,attachment,",")
            Loop
            objMail.AttachFile(trim(Mid(attachment,n0+1)))
        end if
    end if
    objMail.MailFormat = 0 'CdoMailFormatMime
    objMail.BodyFormat = 0 'CdoBodyFormatHTML
    objMail.Send
    set objMail = nothing
    sendmail = err.number
    on error goto 0
end function




Jorge
__________________
Jorge
 
Old March 11th, 2004, 03:54 PM
Authorized User
 
Join Date: Feb 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solution:
http://msdn.microsoft.com/library/de...il_object_.asp

In short:
objMail.AttachFile s, s, 1 '' EncodingMethod setting (0 - CdoEncodeingUUencode, 1 - CdoEncodingBase64)

All the code:

function sendmail(recipient_address, sender_address, subject, body, attachment)
    Dim objMail, n, n0, s
    on error resume next
    set objMail = CreateObject("CDONTS.NewMail")
    objMail.From = sender_address
    objMail.To = recipient_address
    objMail.Subject = subject
    objMail.Body = body
    if trim(attachment) > "" then
        n = InStr(1,attachment,",")
        if n = 0 then
            s = trim(attachment)
            objMail.AttachFile s, s, 1 '' EncodingMethod setting (0 - CdoEncodeingUUencode, 1 - CdoEncodingBase64)
        else
            n0 = 0
            Do while n > 0
                s = trim(Mid(attachment,n0+1,n-n0-1))
                objMail.AttachFile s, s, 1
                n0 = n
                n = InStr(n0+1,attachment,",")
            Loop
            s = trim(Mid(attachment,n0+1))
            objMail.AttachFile s, s, 1
        end if
    end if
    objMail.MailFormat = 0 'CdoMailFormatMime
    objMail.BodyFormat = 0 'CdoBodyFormatHTML
    objMail.Send
    set objMail = nothing
    sendmail = err.number
    on error goto 0
end function


Jorge





Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming an Email File Attachment jpwalters C# 1 May 21st, 2008 12:43 PM
Issue sending HTML file as attachment in EMail kdhawan_forum VB Components 0 April 8th, 2005 02:02 PM
email an attachment GeoMeskin Javascript 1 December 17th, 2003 04:04 PM





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