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

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Morten Abrahamsen (morten.abrahamsen_at_gmail.com)
Date: 09/16/04


Date: Fri, 17 Sep 2004 00:03:25 +0200

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

Jeremy wrote:
> 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 = "jeremyh@mycompany.com"; //for testing
> mm.To = "jeremyh@mycompany.com";
> 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



Relevant Pages

  • Re: About Webservice access Sharepoint site?
    ... The account your webservice is running as doesn't have the required ... to run your webservice as a specified account, with permissions. ... > I am developing a web service to do something with share point. ...
    (microsoft.public.sharepoint.portalserver)
  • RE: SharePoint
    ... Dim strSPSite As String = "http://xxxxxxxxx"; ... Subject: SharePoint ... Do you have access to the web service code to see how it is done there? ... a Windows 2003 server with an admin account running it, ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Asp.Net and Webservice using Impersonation/App Pools
    ... the EXE to the user account that the web service will run as? ... > webservice everything goes smoothly. ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Using kerberosSecurity Throws Security Exception
    ... Account with a Custom Principal Name using SetSPN.exe utility. ... I tried turning on identity impersonation for my web app. ... >> turned on for the web app (the client of my web service). ... >> Non nobis Domine non nobis sed nomini Tuo da gloriam. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Windows Auth to SQL Server from ATL Web Service not working...
    ...  When I hit the web service with a simple test application, ... account I'm logged on as. ... could even be the one the application pool in iis is running under) to ... this impersonation token is not passed on to the SQL Server. ...
    (microsoft.public.vc.atl)