SharpMail
-
<p>Yo tout le monde !</p>
<p> </p>
<p>Suite à un manque d'imagination, j'ai décidé de créer une petite librairie qui va vous permettre d'envoyer des mails en C# plus simplement et plus rapidement.</p>
<p> </p>
<p>Lien de téléchargement : <a href="http://goo.gl/ytgu24" rel="external nofollow">http://goo.gl/ytgu24</a> (Release + Source v0.1) </p>
<p>Lien de la source : <a href="http://goo.gl/biU3s6" rel="external nofollow">http://goo.gl/biU3s6</a> (Github) </p>
<p> </p>
<p>Utilisation :</p>
<p>1) Ajouter la référence au projet</p>
<p>2) Importer la librairie avec : </p>
<pre class="ipsCode prettyprint">
using SharpMail;
</pre>
<p>3) Désormais vous pouvez envoyer des emails comme ceci :</p>
<pre class="ipsCode prettyprint">
SharpMail.Mail.SendMail("smtp.yourserver.com", "[email protected]", "[email protected]", "subject", "message", "[email protected]", "creditential_password", "Mail send !");
</pre>
<p>Certes ce n'est pas forcément très utilie mais comme je vous l'ai dit, je ne suis pas très inspiré en ce moment...</p>
<p>J'espère quand même que ca peut être utile à quelqu'un !</p>
<p> </p>
<p>A+</p>
<p> </p> -
<p>Petit truc que j'ai remarquer:</p>
<p> </p>
<p>-Tu as surchargé la méthode SendMail pour ajouter l'argument "MSGBOXSUCCESS", c'est inutile, puisqu'en C# et il y a les arguments optionels.</p>
<p>ex:</p>
<pre class="ipsCode prettyprint">
public static void SendMail(string SMTP, string FROM, string TO, string SUBJECT, string BODY, string USERNAME, string PASSWORD, string MSGBOXSUCCESS = string.Empty)
</pre>
<p>Ça te permet d'appeler la fonction avec l'argument MSGBOXSUCCESS en option, donc si il n'est pas fourni, il sera égal a string.Empty (ou "").</p>
<p>Et puis au moment d'afficher la messagebox il suffit de check si l'argument a été fourni.</p>
<p>ex:</p>
<pre class="ipsCode prettyprint">
public static void SendMail(string SMTP, string FROM, string TO, string SUBJECT, string BODY, string USERNAME, string PASSWORD, string MSGBOXSUCCESS = string.Empty)
{
/*
...
*/if(MSGBOXSUCCESS != string.Empty)
MessageBox.Show(MSGBOXSUCCESS);/*
...
*/
}
</pre>
<p>- Aucun usage de var</p>
<p>- Un block "using" aurait été préférable pour gérer les exceptions (et après le catch tu devrais mettre un finally pour t'assurer que SmtpServer.Close() est bien exécuté)</p>
<p>- Les noms des arguments pique les yeux
</p>
<p> </p>
<p>En espérant que ça t'aide
</p>
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login