Forum Moderators: open

Message Too Old, No Replies

Sending Email using CDO objMessage.AddAttachment

Send attachment with actual attachment file name and extension

         

FlamesFan

5:46 pm on Sep 7, 2005 (gmt 0)

10+ Year Member



I'm having a problem sending an attachment with the proper file name.
I'm using CDO.Message and I can't seem to find out how to attach or include the file name when I send the attachment. I have seen some sample code for CDONTS but that doesn't work for CDOSYS.
See my code for example:

<%

Dim objMessage

Set objMessage = Server.CreateObject("CDO.Message")

HTML = "<!DOCTYPE HTML PUBLIC'-//IETF//DTD HTML//EN'>"
HTML = HTML + "<html>"
HTML = HTML + "<head>"
HTML = HTML + "<title>Sending Email Request for TRIR info</title>"
HTML = HTML + "</head>"
HTML = HTML + "<body>"
HTML = HTML + "<table width='600' align='center' border='0'>"
HTML = HTML + "<tr>"
HTML = HTML + "<td height='40' valign='top'>"
HTML = HTML + "<img border='0' src='Images/formletter/logo.gif' width='110' height='52' valign='top' align='left'><br>&nbsp"
HTML = HTML + "</td>"
HTML = HTML + "</tr>"
HTML = HTML + "</table>"

HTML = HTML + "</body>"
HTML = HTML + "</html>"
objMessage.From = "xx@xx.com"
objMessage.To = "xx@xx.com"
objMessage.HtmlBody = HTML
objMessage.Subject = "FormLetter"

objMessage.AddAttachment"/attachments/attachment 1.txt"


objMessage.Send()

Response.Redirect( ""+Request.QueryString( "nextpage" ) )
objMessage=nothing

%>

This code works fine, but I want to be able to add the file name as part of email. Currently when I send the email the attachment appears as ATT84302.txt

Any help would be nice.

Easy_Coder

1:50 am on Sep 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is that file actually attaching? I thought you had to fully qualify an attachment with cdo...

objMessage.AddAttachment "c:\attachments\attachment%201.txt"

FlamesFan

1:40 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Yes the file is attaching, I had removed the server name before I posted.

Easy_Coder

4:17 pm on Sep 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I did notice that you had a space in the file name... probably not causing your problem but you should rule that out.

^
ignore that... you already indicated that it's delivering

FlamesFan

4:33 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Yes, sending the attachment is not the problem, I'd like to be able to name the attachment, either hard coded or capture it from the attachment name. I have seen code for the cdonts method using attachFile, but that doesn't seem to work for cdosys method.

Easy_Coder

5:23 pm on Sep 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



would that be the Calgary Flames, FlamesFan?

FlamesFan

5:34 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



I am a Calgary Flames Fan.

I have been since they won the cup in 1989.

Living in Calgary during the last hockey playoffs (03-04 season) was something for a true hockey fan to experience. Can't wait till the season starts this year.

Easy_Coder

5:50 pm on Sep 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



not rubbin it in or nothing but I live in tampa and I got to drink booze out of the cup last summer.

FlamesFan

6:01 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



I don't like you already!

"Drink from the cup in Tampa"

Tampa has a great team, not sure how well they'll do this year, no goalie. But if they can take advantage of the new rules which should allow their stars to shine, they'll do ok this year.

I'm still not cheering for them though.