• Super User

    Che errore hai? Che server hai utilizzato?


  • User

    Ciao, grazie per la rispasta imediata !:D
    ti posto il cadice completo :

    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Net.Mail;
     
    namespace WindowsApplication1
    {
    publicpartialclassForm1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    publicbool Send(string from, string to, string subject, string body, MailPriority priority, string[] attachments, bool IsHTMLBody)
    {
    MailMessage msg = null;
    try
    {
    msg = newMailMessage();
    msg.From = newMailAddress(from);
    msg.To.Add(to.Replace(';', ','));
    msg.Subject = subject;
    msg.Body = body;
    msg.IsBodyHtml = IsHTMLBody;
    msg.Priority = priority;
    if (attachments != null)
    {
    foreach (string file in attachments)
    {
    msg.Attachments.Add(newAttachment(file));
    }
    }
    SmtpClient client = newSmtpClient("mail.libero.it");
    client.UseDefaultCredentials = true;
    client.Send(msg);
    returntrue;
    }
    catch (Exception ex)
    {
    string message = ex.Message;
    while ((ex = ex.InnerException) != null)
    {
    message += " -- " + ex.Message;
    }
    //Log del messaggio d'errore...
    returnfalse;
    }
    finally
    {
    if (msg != null)
    msg.Dispose();
    }
    }
    privatevoid button1_Click(object sender, EventArgs e)
    {
    Send(string [email protected], string [email protected], string subject, string body, MailPriority priority, string[] attachments, bool IsHTMLBody);
    }
    }
    }
    
    

    gli errori sono :

    
    ------ Inizio generazione: Progetto: WindowsApplication1, Configurazione: Debug Any CPU ------
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /debug:full /optimize- /out:obj\Debug\WindowsApplication1.exe /resource:obj\Debug\WindowsApplication1.Form1.resources /resource:obj\Debug\WindowsApplication1.Properties.Resources.resources /target:winexe Form1.cs Form1.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,22): errore CS1525: 'string' è un termine non valido nell'espressione
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,30): errore CS1026: È previsto il segno )
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,40): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,40): errore CS1525: ',' è un termine non valido nell'espressione
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,42): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,57): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,67): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,67): errore CS1525: ',' è un termine non valido nell'espressione
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,69): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,85): errore CS1041: È previsto un identificatore, 'string' è una parola chiave
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,111): errore CS1044: Impossibile utilizzare più di un tipo nelle istruzioni for, using, fixed e nelle dichiarazioni
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,121): errore CS1041: È previsto un identificatore, 'string' è una parola chiave
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,143): errore CS1041: È previsto un identificatore, 'bool' è una parola chiave
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,158): errore CS1002: È previsto un punto e virgola (;)
    C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,158): errore CS1525: ')' è un termine non valido nell'espressione
    Compilazione completata: 15 errori, 0 avvisi
    ========== Generazione: 0 completate o aggiornate, 1 non riuscite, 0 ignorate ==========
    
    

    Misà che ho sbagliato in molti punti ! :bho:


  • Super User

    Senza offesa, ma credo che prima sarebbe il caso di legere un manuale di C#.
    L'erore te lo da qui

    privatevoid button1_Click(object sender, EventArgs e)
    {
    Send(string [email][email protected][/email], string [email][email protected][/email], string subject, string body, MailPriority priority, string[] attachments, bool IsHTMLBody);
    }

    Dovrebbe essere qualcosa del tipo

    privatevoid button1_Click(object sender, EventArgs e)
    {
    Send("[email protected]", "[email protected]", "", "", MailPriority.something, new string[10], true);
    }

    Al metodo send devi passargli i parametr, non ci puoi riscrivere string!!


  • User

    Si scusami tanto sono proprio uno stupido ! :arrabbiato:
    Ho sbagliato una cosa che sapevo, tempo fà usavo il c++ quindi i metodi (o funzioni) le so, solo che oggi veramente non sò cos'ho !
    Comunque adessa che ho sistemato i parametri me de questi errori :

    
    Errore 1 'System.Net.Mail.MailPriority' non contiene una definizione per 'something' C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs 64
    
    
    

    Scusami ancora !
    E grazie per l'aiuto ! 😄


  • Super User

    Beh io ho scritto MailPriotiy.something perchè non sapevo che c'è dentro MailPriority, che è un'enumeration (ci sono anche in c+++). Comunque prova con MailPriority.Normal, oppure vedi cosa ti dice intellisense....


  • User

    Ho cambiato in MailPriority.Normal ed ora compila il tutto ! 😄
    Una volta eseguita però schiaccio il pulsante invia ed non da errori ma se controllo la email non arriva ! :bho:


  • Super User

    Credo che libero non ti permette di inviare mail se non hai la connessione di libero, prova altro, che so tiscali o alice...


  • User

    Ciao, ne ho provato una valanga. ho inserito perfino una textbox per cambiarle velocemente mentre è in esecuzzione ! :arrabbiato:
    Mi sembra strano che nemmeno 1 vada ho trovato questo :

    http://www.freepops.org/it/smtplist.php

    forse può essere utile a qualcuno ! 😄


  • Super User

    Non so, se la mail è giusta dovrebbe andare... Hai scritto qualcosa in subject e body? Da qualche eccezione?


  • User

    Si ho scritto una parola sia in subject che in body ! :bho:
    Cosa intendi con eccezine ?

    Errori non ne dà nemmeno 1 !

    Ciao
    Grazie


  • Super User

    Eccezioni sono errori. Allora mi spiace ma non so da cosa possa dipendere, io ho provato e va. Non so se va solo su web e non da programma. Sicuro che il firewall o roba del genere non bloccano il collegamento del tuo programma?


  • User Attivo

    Se hai l'smtp in locale potresti provarlo da li...
    Difficilmente gli hosting gratuiti ti faranno spedire mail.
    Spesso anche quelli a pagamento ti fissano i limiti.


  • Super User

    @FuSioNmAn said:

    Se hai l'smtp in locale potresti provarlo da li...
    Difficilmente gli hosting gratuiti ti faranno spedire mail.
    Spesso anche quelli a pagamento ti fissano i limiti.
    Già, potresti provare qualcosa come html2pop3, ti fa creare anche un smtp in locale...


  • User

    Ciao, Praticamente dovrei istallarmi un programma che mi crea stmp nel mio pc cosi mi appogio al localhost per spedire le email ?
    Ma poi se voglio passarlo a qualche mio amico deve istallare anche lui quel progranna ? :bho:
    Comunque io ho fastweb e ho provato ad inserire il server stmp smtp.fastwebnet.it, in Outlook e spedisce le email senza problema, invece con il programmino che ho fatto nisba ! :bho:

    Grazie 1000 ! :ciauz:


  • Super User

    Sinceramente non so, non ho mai provato a inviare mail direttamente da un programma... Ma avviare outlook per spedire la mail no? come fa un browser quandoi clicchi su un indirizzo email?


  • Super User

    Ho trovato qualcosa del genre, prova magari va...

    MailMessage theMailMessage = new MailMessage("[email protected]", "[email protected]");
    theMailMessage.Body = "body email message here";
    theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment"));
    theMailMessage.Subject = "Subject here";

    SmtpClient theClient = new SmtpClient("IP.Address.Of.Smtp");
    theClient.UseDefaultCredentials = false;
    System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("[email protected]", "password");
    theClient.Credentials = theCredential;
    theClient.Send(theMailMessage);


  • User

    Grazie, che riferimento devo inserire ? 😄


  • Super User

    Non so cosa intendi con riferimento, comunque se intendi nome utente e password, prova con le tue. In ogni caso per l'smtp ha senso usare nome utente e password solo se lo richiede lui, come fanno in genere tutti gli hosting o gmail...


  • User

    Ciao, per riferimento intendo :

    using System.Net.Mail;

    comunque l'ho provato ma non và il server mi risponde :

    Informazioni aggiuntive: Cassetta postale non disponibile. Risposta del server: RCPT TO:[email protected] Relaying not allowed


  • Super User

    Prova a cambiare indirizzo... comunquecome detto se usi

    System.Net.NetworkCredential("[email protected]", "password")

    poi devi usare il server smtp di name.com (oppure libero oppure gmail ecc, ma entrambi gli stessi)