Excel attachment smtp IIS7 (or any attachments)

Hi Experts,

I think I'm a little over my head here, and I'm getting really frustrated as to why this is so complex?!

I'm writing files that go into a IIS7 pickup folder that get emailed. This works - I'm happy with that.
I'm now trying to attach excel files in each email, but that's seemingly difficult (why? - seriously WHY is this so difficult?!)

I've searched google and here and I can't find anything, I can only assume I'm searching for the wrong thing.
Let's face it - I thought this would be easier to find a solution because surely everyone would think this should be simple?!

Anyway, here's the code I have going into the pickup folder (some of it was found via google, so I'm not 100% sure what it does, but it was a start) - it attaches a file, but the file doesn't work. It also comes through as "Ctempttest.xls" instead of just "test.xls":

To:email@address.com
From:email@address.com
Reply-To:email@address.com
Subject:Testing Attachments
MIME-Version:1.0
Content-Type:multipart/mixed;
  Boundary="Attached"

--Attached
Content-Type:text/html;
<b>piss</b>&nbsp;<u>off</u>

--Attached
Content-Type: application/vnd.ms-excel; 
  name="Hello.xls"
Content-Disposition: attachment; 
  filename="C:\temp\test.xls"

Open in new window


Getting angry over this (as you can probably tell!)
LVL 5
INHOUSERESAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

INHOUSERESAuthor Commented:
(sorry for the bad language - I forgot I put that in the body of the email!)
0
Dan McFaddenSystems EngineerCommented:
In the code, I would use a double back slash in the filepath.  It would look like this:

filename="C:\\temp\\test.xls"

Which is escaping the backslash.

Dan
0
INHOUSERESAuthor Commented:
Hi Dan,

Thanks for the comment.

Didn't make any difference unfortunately.
If I save the attachment that comes through, and open it in Notepad, it's completely blank. It's as if it's creating a new file and trying to name it as the location instead of taking the file I want it to.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Dan McFaddenSystems EngineerCommented:
Have you tried placing the attached file in the same directory as the .eml file?  then the filename key would look like:

filename="test.xls"

Are you using a script to do this?
0
INHOUSERESAuthor Commented:
A script generates a text file that goes into the pickup directory. Placing any files in the pickup folder gets set automatically - it will only process files in the right format.

I know that is all working because it sends an email.
The issue is definitely the code to attach a file. Most likely this part:
--Attached
Content-Type: application/vnd.ms-excel; 
  name="Hello.xls"
Content-Disposition: attachment; 
  filename="C:\temp\test.xls"

Open in new window

0
Dan McFaddenSystems EngineerCommented:
What scripting language are you using?
0
INHOUSERESAuthor Commented:
It's a project in VBA attached to an MSAccess database that is creating text files that go into that pickup folder.

I've no idea what language it is outputting. It's via SMTP.
0
Dan McFaddenSystems EngineerCommented:
I'd guess VBScript.

Why not have the script just send the email through the SMTP server instead of writing to a file object?  The CDONTS object is much more efficient.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
INHOUSERESAuthor Commented:
I think I'm gunna have to rethink this then. It looks like this is just to complex as it is.

Thanks Dan for the contribution. I'll check out CDO.
0
Dan McFaddenSystems EngineerCommented:
If interested, I have, somewhere, vbscripts with CDONTS for a similar task.  It could be a starting point for you.

You could message if interested.

Dan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.