В терминологии компилятора противоположное является "несинтаксическим анализом". А именно, парсинг превращает поток маркеров в абстрактные синтаксические деревья, в то время как непарсинг превращает абстрактные синтаксические деревья в поток маркеров.
mailto: официально не поддерживает вложения. Я слышал, что Outlook 2003 будет работать с таким синтаксисом:
<a href='mailto:name@domain.com?Subject=SubjTxt&Body=Bod_Txt&Attachment=""C:\file.txt"" '>
Лучший способ справиться с этим - отправить почту на сервер, используя System.Net.Mail.Attachment .
public static void CreateMessageWithAttachment(string server)
{
// Specify the file to be attached and sent.
// This example assumes that a file named Data.xls exists in the
// current working directory.
string file = "data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"jane@contoso.com",
"ben@contoso.com",
"Quarterly data report.",
"See the attached spreadsheet.");
// Create the file attachment for this e-mail message.
Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try {
client.Send(message);
}
catch (Exception ex) {
Console.WriteLine("Exception caught in CreateMessageWithAttachment(): {0}",
ex.ToString() );
}
data.Dispose();
}
Действительно ли этому приложению нужно использовать Outlook? Есть ли причина не использовать пространство имен System.Net.Mail?
Если вам действительно нужно использовать Outlook (и я бы не рекомендовал его, потому что тогда вы основываете свое приложение на сторонних зависимостях, которые могут измениться ) вам нужно будет изучить пространства имен Microsoft.Office
. Я бы начал здесь: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.aspx
Если вы хотите получить доступ к почтовому клиенту по умолчанию, вы можете использовать MAPI32.dll (работает только в ОС Windows). Взгляните на следующую оболочку:
http://www.codeproject.com/KB/IP/SendFileToNET.aspx
Код выглядит следующим образом:
MAPI mapi = new MAPI();
mapi.AddAttachment("c:\\temp\\file1.txt");
mapi.AddAttachment("c:\\temp\\file2.txt");
mapi.AddRecipientTo("person1@somewhere.com");
mapi.AddRecipientTo("person2@somewhere.com");
mapi.SendMailPopup("testing", "body text");
// Or if you want try and do a direct send without displaying the mail dialog
// mapi.SendMailDirect("testing", "body text");