SmtpMail

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi

not sure if this is the write place, but i really need some help with
this...!
I have a piece of code that sends email using the SmtpMail class, in an
ASP.NET web application, with integrated window authentication.
it does work, and works fine on my dev machine. it also works fine on the
test server, but with some considerations.
on the test server, i can send emails IF they do not include any
attachments. as soon as i send an email WITH an attachment i get a
"System.Runtime.InteropServices.COMException (0x80004005): Unspecified
error" error. you gotta love that error message.

so the test server works, when NOT sending with attachments.
i then put myself as an administrator on the test web server. i can now send
as many emails as i want, and with attachments.

why is this? due to this behaviour i suspect it's a permissions problem on a
temporary folder somewhere?

Thanks
Jason
 
Jason,

Are you sure that the attachments are not in a seperated directory for what
the user from smtp has no authoritiy too.

That would be my first check when I see your question.

Cor
 
Well the directories are created on the fly. in other words, i see that
DOMAIN\user1 is connecting so i use that as the temporary folder. the files
are then put inside this folder and sent from there...
the folders are created properly. and so are the files, the email just fails
*sob*

thanks for the reply..
 
hi,

it seems to be a permission problem , where is your attachment located? if
it's outside your application directory that may happen

can you post the code you are using?

cheers,
 
Hi, thanks for the reply, here is the code. The folder is created by the web
application using the user's logon as the folder name. the folder is within
the web app.
i.e. wwwroot\ThisIsTheFolder\DOMAIN\usrename

as you can also see from the code, there is a File.Exists check, and i have
logging which confirms the file does exist and is added as an attachment
successfully.

the problem is on the actual SmtpMail.Send(mailMess);

as said in the previous post, the folders and the files are created on the
fly AND are created successfully.

Thanks again
Jason

MailMessage mailMess = null;

mailMess = new MailMessage();
if (!bUseBCC)
{
mailMess.To = strRecipients;
}
else
{
mailMess.To = strFrom;
mailMess.Bcc = strRecipients;
}
mailMess.From = strFrom;
mailMess.Subject = strSubject;

mailMess.Body = strMessage;

mailMess.BodyFormat = MailFormat.Html;

if (htAttachments != null)
{
foreach (DictionaryEntry entry in htAttachments)
{
string strFile = entry.Value.ToString();
if (System.IO.File.Exists(strFile))
{
MailAttachment attachmentObj = new MailAttachment(strFile,
System.Web.Mail.MailEncoding.Base64);
mailMess.Attachments.Add(attachmentObj);
}
}
}


mailMess.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverpo
rt"] = port;

mailMess.Fields["http://schemas.microsoft.com/cdo/configuration/smtpconnecti
ontimeout"] = 60;
SmtpMail.SmtpServer = strSMTPServer;
SmtpMail.Send(mailMess);
 
perhaps i should also mention

the file to be sent, is being loaded from a database and being saved to disk
using a FileStream. logging also confirms that this file was successfully
written to disk AND closed.

1. user opens page
2. clicks button to send email with attachments
3. button event
- finds the file in the database
- creates the folder
- creates the file from the database
- closes the file
- compiles message
- sends (fails)
- delete the files from the folder

like i said in previous posts, the SmtpMail.Send is what fails.
 
Jason,

Did you try it already with standard UU encoding (with only the path
parameter)?

Cor
 
yes, that was how it first was coded. i tried putting in the UUEncoding
after the problem started...
 
Jason,

I still see the problem in the authorization
..
Can you not try it with a dummy attachment in a folder that is absolute sure
for the ASPNET user by not making it on the fly however creating it, and
than giving all the rights with the hand to that ASPNET user.

Cor
 
Back
Top