>Ciao a tutti
>come faccio a inviare una mail con allegata un file presente
>sul server?
Beh, ti riporto un esempio tratto dall'SDK:
//This example shows how to programmatically add attached files
//to a mail lessage.
MailMessage myMail = new MailMessage();
// Concatenate a list of attachment files in a string.
string sAttach = @"C:\images\image1.jpg,C:\images\image2.jpg,C:\images\image3.jpg";
// Build an IList of mail attachments using the files named in the string.
char[] delim = new char[] {','};
foreach (string sSubstr in sAttach.Split(delim))
{
MailAttachment myAttachment = new MailAttachment(sSubstr);
myMail.Attachments.Add(myAttachment);
}
In questo esempio vengono inseriti ben 3 allegati.
A te ne basta uno. Se l'allegato è sul Server è sufficiente che rilevi il percorso fisico esatto cioè c:\web\ecc. e di solito si fa uso del metodo Server.MapPath("/") che ti restituisca il percorso fisico della root del sito.
Ciao
David De Giacomi | Microsoft MVP
http://blogs.dotnethell.it/david/