Solved

Excel attachment smtp IIS7 (or any attachments)

Posted on 2014-11-12
10
191 Views
Last Modified: 2014-11-17
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!)
0
Comment
Question by:INHOUSERES
  • 5
  • 5
10 Comments
 
LVL 5

Author Comment

by:INHOUSERES
ID: 40436909
(sorry for the bad language - I forgot I put that in the body of the email!)
0
 
LVL 27

Expert Comment

by:Dan McFadden
ID: 40437320
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
 
LVL 5

Author Comment

by:INHOUSERES
ID: 40437350
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 27

Expert Comment

by:Dan McFadden
ID: 40437455
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
 
LVL 5

Author Comment

by:INHOUSERES
ID: 40437479
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
 
LVL 27

Expert Comment

by:Dan McFadden
ID: 40437482
What scripting language are you using?
0
 
LVL 5

Author Comment

by:INHOUSERES
ID: 40437562
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
 
LVL 27

Accepted Solution

by:
Dan McFadden earned 500 total points
ID: 40437843
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
 
LVL 5

Author Comment

by:INHOUSERES
ID: 40446775
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
 
LVL 27

Expert Comment

by:Dan McFadden
ID: 40446785
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now