-
_SMTP è proprio l'indirizzo smtp con cui puoi inviare e-mail, tra l'altro il tuo codice dovrebbe dare errore proprio perchè non hai specificato questo indirizzo.
Se questo non è specificato il .net utilizza come indirizzo di default "localhost".
Ciao


-
-
-
Ma scusa il tuo provider non ti ha fornito l'indirizzo del server SMTP a cui appoggiarti per gestire le Mail?

-
Si me lo ha dato, ma il dominio è registrato con un altro, e finchè non faccio il redirect, l'smtp mail.miosito.it punterà a qualche altra cosa e non all'SMTP dell'hosting in cui sto... Per ora sto solo facendo qualche test per assicurarmi che funziona, prima di passare tutto li!
-
artcava
Io mi sono scritto questo metodo...
using System.Net.Mail; public bool Send(string from, string to, string subject, string body, MailPriority priority, string[] attachments, bool IsHTMLBody) { MailMessage msg = null; try { msg = new MailMessage(); msg.From = new MailAddress(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(new Attachment(file)); } } SmtpClient client = new SmtpClient(_SMTP); client.UseDefaultCredentials = true; client.Send(msg); return true; } catch (Exception ex) { string message = ex.Message; while ((ex = ex.InnerException) != null) { message += " -- " + ex.Message; } //Log del messaggio d'errore... return false; } finally { if (msg != null) msg.Dispose(); } }E' in C#, se ti serve in VB non è difficile farne la conversione...

Ciao a tutti !

Questo è il mio primo post in questo forum !Vorrei porre una domanda al creatore di qurl metodo:
Intanto incomincio col dire che non uso da tanto il c# quindi tante cose non le capisco ancora, la mia domanta e: ho provato ad inserire in un programma quel metodo e nauralmente a inserire anche il server stmp, pero non riesco a farla funzionare, non è che saresti cosi gentile da farmi un esempio pratico, perche è da tempo che sto sercando di inviare email in c# ma non ci sono mai riuscito ! :bho:
O al limite se mi puoi indicare un sito dove scaricare un esempio !
Io uso Visual Studio C# 2005 pro !Grazie in anticipo !
-
-
Ciao, grazie per la rispasta imediata !:D
ti posto il cadice completo :[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections.Generic;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.ComponentModel;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Data;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Drawing;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Text;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Windows.Forms;[/SIZE] [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Net.Mail;[/SIZE] [SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] WindowsApplication1[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]partial[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Form1[/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#008080]Form[/COLOR][/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] Form1()[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2]InitializeComponent();[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] Send([/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] from, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] to, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] subject, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] body, [/SIZE][SIZE=2][COLOR=#008080]MailPriority[/COLOR][/SIZE][SIZE=2] priority, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2][] attachments, [/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] IsHTMLBody)[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#008080]MailMessage[/COLOR][/SIZE][SIZE=2] msg = [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2];[/SIZE] [SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE] [SIZE=2]{[/SIZE] [SIZE=2]msg = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]MailMessage[/COLOR][/SIZE][SIZE=2]();[/SIZE] [SIZE=2]msg.From = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]MailAddress[/COLOR][/SIZE][SIZE=2](from);[/SIZE] [SIZE=2]msg.To.Add(to.Replace([/SIZE][SIZE=2][COLOR=#800000]';'[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]','[/COLOR][/SIZE][SIZE=2]));[/SIZE] [SIZE=2]msg.Subject = subject;[/SIZE] [SIZE=2]msg.Body = body;[/SIZE] [SIZE=2]msg.IsBodyHtml = IsHTMLBody;[/SIZE] [SIZE=2]msg.Priority = priority;[/SIZE] [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (attachments != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2])[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#0000ff]foreach[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] file [/SIZE][SIZE=2][COLOR=#0000ff]in[/COLOR][/SIZE][SIZE=2] attachments)[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2]msg.Attachments.Add([/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Attachment[/COLOR][/SIZE][SIZE=2](file));[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#008080]SmtpClient[/COLOR][/SIZE][SIZE=2] client = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]SmtpClient[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"mail.libero.it"[/COLOR][/SIZE][SIZE=2]);[/SIZE] [SIZE=2]client.UseDefaultCredentials = [/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2];[/SIZE] [SIZE=2]client.Send(msg);[/SIZE] [SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2];[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#008080]Exception[/COLOR][/SIZE][SIZE=2] ex)[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] message = ex.Message;[/SIZE] [SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE][SIZE=2] ((ex = ex.InnerException) != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2])[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2]message += [/SIZE][SIZE=2][COLOR=#800000]" -- "[/COLOR][/SIZE][SIZE=2] + ex.Message;[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#008000]//Log del messaggio d'errore...[/COLOR][/SIZE] [SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][SIZE=2];[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#0000ff]finally[/COLOR][/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (msg != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2])[/SIZE] [SIZE=2]msg.Dispose();[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#008080]EventArgs[/COLOR][/SIZE][SIZE=2] e)[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2]Send([/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] [email protected], [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] [email protected], [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] subject, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] body, MailPriority priority, [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2][] attachments, [/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] IsHTMLBody);[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE] [SIZE=2]}[/SIZE]gli errori sono :
[SIZE=1]------ Inizio generazione: Progetto: WindowsApplication1, Configurazione: Debug Any CPU ------[/SIZE] [SIZE=1]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[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,22): errore CS1525: 'string' è un termine non valido nell'espressione[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,30): errore CS1026: È previsto il segno )[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,40): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,40): errore CS1525: ',' è un termine non valido nell'espressione[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,42): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,57): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,67): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,67): errore CS1525: ',' è un termine non valido nell'espressione[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,69): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,85): errore CS1041: È previsto un identificatore, 'string' è una parola chiave[/SIZE] [SIZE=1]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[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,121): errore CS1041: È previsto un identificatore, 'string' è una parola chiave[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,143): errore CS1041: È previsto un identificatore, 'bool' è una parola chiave[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,158): errore CS1002: È previsto un punto e virgola (;)[/SIZE] [SIZE=1]C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs(64,158): errore CS1525: ')' è un termine non valido nell'espressione[/SIZE] [SIZE=1]Compilazione completata: 15 errori, 0 avvisi[/SIZE] [SIZE=1]========== Generazione: 0 completate o aggiornate, 1 non riuscite, 0 ignorate ==========[/SIZE]Misà che ho sbagliato in molti punti ! :bho:
-
Senza offesa, ma credo che prima sarebbe il caso di legere un manuale di C#.
L'erore te lo da quiprivatevoid button1_Click(object sender, EventArgs e)
{
Send(string [email protected], string [email protected], 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!!
-
Si scusami tanto sono proprio uno stupido !

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 :[SIZE=1]Errore 1 'System.Net.Mail.MailPriority' non contiene una definizione per 'something' C:\Documents and Settings\The_King\Desktop\WindowsApplication1\WindowsApplication1\Form1.cs 64 [/SIZE]Scusami ancora !
E grazie per l'aiuto !
-
-
-
-
Ciao, ne ho provato una valanga. ho inserito perfino una textbox per cambiarle velocemente mentre è in esecuzzione !

Mi sembra strano che nemmeno 1 vada ho trovato questo :http://www.freepops.org/it/smtplist.php
forse può essere utile a qualcuno !

-
-
-
-
-
FuSioNmAn
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...
-
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 !

Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi