Hi I have a simple aspx C# script page that uploads a file and some address and sends an email with uploaded file as attachment. This all works fine from a browser, no problem, but that is not what I am trying to do
.
I am using this control:
<p>
Select File to Send:
<input id="File1"
type="file"
runat="server">
<p>
Select File to Send:
<input id="File1"
type="file"
runat="server">
on the sever part my script goes like this:
<html>
<head>
<script language="C#" runat="server">
void Button1_Click(object Source, EventArgs e)
{
if (FromAddr.Value == "")
{
Span1.InnerHtml = "Error: you must enter a Email Addr";
return;
}
if (File1.PostedFile.FileName != "")
{
try
{
MailMessage aMessage = new MailMessage(FromAddr.Value, ToAddr.Value);
aMessage.Subject = Subject.Value;
aMessage.Body = Message.Value;
// set up the attachment
ContentType ct = new ContentType(MediaTypeNames.Application.Octet);
Attachment data = new Attachment(File1.PostedFile.InputStream, ct);
ContentDisposition disposition = data.ContentDisposition;
disposition.FileName = AttachName.Value;
aMessage.Attachments.Add(data);
SmtpClient client = new SmtpClient("<some host>");
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(aMessage);
data.Dispose();
Span1.InnerHtml = "Send Success: ";
}
catch (Exception exc)
{
Span1.InnerHtml = "Send failure: " +
ToAddr.Value + "</b><br>" + exc.ToString();
}
}
the rub is I want to do this from within a c++ application so I wrote a class to mimic the browser, it pulls down the HTTP get page load. gets the validate ID and state codes and builds up a post message. This works fine with text files but as soon as I try binary it chokes.
It appears to time out waiting for a reply from the server as if it is expecting more data. Does anyone have any ideas? I have been banging my head against this wall for a bit. Thanks!