Using SMPTMail, MailAttachment corrupts the attachment when called from a web service

J

Jeremy

I creating a very simple email, and attaching an excel file and trying
to send it.

When I do this with a standalone executable, everything works fine.
When I include it as part of a web service, where we're impersonating
a domain account, it corrupts the attachment. The xls file is 270Kb
on the server, but when the email is sent from the web service, the
attched file is only 300b.

Does anyone have any ideas of why this is happening ONLY when called
from a web method?

Here is the code that FAILS, inside the web service, but works when
called from a windows application...

////////////////////////////////////////////////////

MailMessage mm = new MailMessage();
mm.From = "(e-mail address removed)"; //for testing
mm.To = "(e-mail address removed)";
mm.Subject = "Subject";
mm.Body = "Body";
mm.BodyEncoding = Encoding.ASCII;
mm.BodyFormat = MailFormat.Text;
mm.Priority = MailPriority.Normal;
string strFile = @"C:\ExcelFiles\Variance Request(421).xls";
mm.Attachments.Add(new MailAttachment(strFile,
MailEncoding.UUEncode));
SmtpMail.SmtpServer = "mail.mycompany.com";
SmtpMail.Send(mm);



-Jeremy
 
M

Morten Abrahamsen

This might be a long shot, but since we're working in two different
security contexts;

Does the ASP.NET account (or whatever account your WebService is using)
have access to the file ?

Morty
 
J

jeremy halbert

I do have access to the file. If the file is smaller, it works just
fine, I only have problems when the file is large (250Kb)

And here's another thing I found. The SMPT virtual server IIS settings
limit non admins to 2048b for the size of emails they can send. I
changed that to a grossly large number, and it still had the same
problem.

But, when I added the account I was using to be an admin on that
machine, then it worked just fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top