Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

sending mail with binary attachments?
I am trying to do a mail out to membership list.

I have a cover letter and two attachments.  The first is in word format
text document and the second is a png image.

I am using the dg_mail code from the wiki http://mini.net/tcl/1014.

I can send mail, I can send a text attachment, but I can not properly send
the cover letter with the pair of binary attachments.

The example works fine (sends a copy of the .tcl code as an attachment):

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

## example code works fine - send body with text attachment.
array set attcs_options {}
set attcs [file join [pwd] [info script]]

foreach attc $attcs {
## charset is optional
set opts [list -canonical "text/plain; charset=ascii; name=\"[file tail $att
c]\""]
lappend opts -encoding quoted-printable
lappend opts -header {Content-Disposition attachment}
lappend opts -file $attc
set attcs_options($attc) $opts
}

dg_mail::sendmail sinisa@datagram.dg djoko2000@datagram.dg {Tcl smtp!} Hello
! "" "" \
-file [namespace current]::attcs_options
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

When I try to send my binary attachments, the mail is sent but the
attachments are included in the text as binary gibberish.  Clicking on the
attached file names in firefox, firefox complains that the attachments
are not in the correct format.

I suspect I need some more options set, but what options and what values?

Any thoughts?
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
#send mail attachment1 attachment1
set smtphost   "..."
set from        ...
set toList      ...
set subject    "..."
set body       "..."
set header [list Date "[clock format [clock seconds]]"]
set bcc ""
set opt_attcs_type -file

set attc $attachment1 ;# word doc
array set attcs_options {}
set opts [list -canonical "text/doc; name=\"$attc\""]
#lappend opts -encoding binary ;# makes no difference
#lappend opts -header {Content-Disposition attachment} ;# makes no
difference
lappend opts -file [file join [pwd] $attc]
set attcs_options($attc) $opts

set attc $attachment2 ;# png image
array set attcs_options {}
set opts [list -canonical "image/png; name=\"$attc\""]
#lappend opts -encoding binary ;# makes no difference
#lappend opts -header {Content-Disposition attachment} ;# makes no
difference
lappend opts -file [file join [pwd] $attc]
set attcs_options($attc) $opts

# dg_mail::sendmail to from subject body {headers} {bcc} {opt__type} {attcs_
array_name}

dg_mail::sendmail $toList $from $subject $body $header $bcc \
$opt_attcs_type [namespace current]::attcs_options

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


Report this thread to moderator Post Follow-up to this message
Old Post
Anchor
04-24-05 08:58 AM


Re: sending mail with binary attachments?
All fixed!


set smtphost   "..."
set from        "\"Membership Committee\" <membership@...>"
set toList      "<...@...>"
set subject    "docs attached"

set header [list Date "[clock format [clock seconds]]"]
set bcc ""

set attcs_type -file

set attc $attachment1 ;# word doc
array set attcs_options {}
set opts [list -canonical "application/octet-stream; name=\"[file tail $attc
]\""]
lappend opts -header {Content-Disposition attachment}
lappend opts -file [file join [pwd] $attc]
set attcs_options($attc) $opts

set attc $attachment2 ;# png image
array set attcs_options {}
set opts [list -canonical "image/png; name=\"[file tail $attc]\""]
lappend opts -header {Content-Disposition attachment}
lappend opts -file [file join [pwd] $attc]
set attcs_options($attc) $opts

dg_mail::sendmail $toList $from $subject $body $header $bcc $attcs_type [nam
espace current]::attcs_options


Report this thread to moderator Post Follow-up to this message
Old Post
Anchor
04-25-05 01:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.