C# Application - How to send an email | FoxLearn

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • How to send an email in c#. send e-mail via SMTP using C#, sending email in .NET through Gmail, sending email through SMTP. The C# Basics beginner course is a free C# Tutorial Series that helps beginning programmers learn the basics of the C# Programming Language.
    How to send email using c#
    C# Tutorial: Email Sender [Send e-mails using C#]
    C# - How To Send An Email Using C# [with source code]
    How to Send SMTP Email from Computer to Webmail using C#

Komentáře • 375

  • @obsilva
    @obsilva Před 7 lety

    Dude, you saved me.
    For hours i have been trying to do this, but Gmail block me. The tip for allow less secure apps works for me.
    Thanks!

    • @foxlearn
      @foxlearn  Před 7 lety

      You're welcome. Thank you !

  • @abdallahmamdouh2270
    @abdallahmamdouh2270 Před 4 lety +2

    it's not working with me and there is no error on send what is the problem

  • @andyglbrt
    @andyglbrt Před 6 lety

    Thank you! It has been difficult to find a good, simple example of how to execute sending email in C#. This worked for me just fine. I plan to use it in another program to send auto-mails to myself as notifications.

  • @vexxy9879
    @vexxy9879 Před 4 lety +7

    make a loop, add the send function in there and done, you now have an email spammer

  • @coleykat312
    @coleykat312 Před 3 lety +2

    Can someone please help me whenever I send it says '@' is a invalid charector. 9:01 it was typed. what is it for? its not working can someone pls help meh

  • @MrRamonGimenez
    @MrRamonGimenez Před 7 lety

    Muy buen video! Muchas gracias por el aporte. The video is very good! ThankYou very much, sorry for my english, is not good.

    • @foxlearn
      @foxlearn  Před 7 lety

      Ok. You're welcome. Thank you so much ^_^

  • @gametrolling2746
    @gametrolling2746 Před 7 lety

    thank you works like a charm :) easy and usefull thank you soo much

  • @chocchocgaming7788
    @chocchocgaming7788 Před 8 lety +1

    I'm getting an error"FormatException was not unhandled"
    The specified string is not in the form required for an e-mail address.
    Could you please help?

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, Please check your email format, and try again. thanks

  • @lucasbraga8569
    @lucasbraga8569 Před 6 lety

    I'm having a problem with "client.Port = Convert.ToInt32(txtPort.Text);".
    System.FormatException: 'A cadeia de caracteres de entrada não estava em um formato correto.'
    What can I do?

  • @AmanKumar-bi4jl
    @AmanKumar-bi4jl Před 3 lety

    Can i add any ads on my c# application

  • @dipakakhade4636
    @dipakakhade4636 Před 8 lety

    Love u. Worked Awesome As expected.

    • @foxlearn
      @foxlearn  Před 8 lety

      +DIPAK AKHADE Thank you very much :)

  • @ivannarykin
    @ivannarykin Před 3 lety

    Great video. As usually. Thank you very much.
    Now we know how to send mails.
    And how can we arrange a mail receiving?

    • @foxlearn
      @foxlearn  Před 3 lety

      Thank you for your suggestion. Let me try to research

    • @cadethomas142
      @cadethomas142 Před 3 lety

      you all probably dont give a damn but does any of you know of a way to get back into an instagram account..?
      I stupidly lost the account password. I would appreciate any tips you can offer me.

    • @lewisboston6014
      @lewisboston6014 Před 3 lety

      @Cade Thomas Instablaster ;)

    • @cadethomas142
      @cadethomas142 Před 3 lety

      @Lewis Boston Thanks so much for your reply. I found the site through google and Im trying it out now.
      Takes a while so I will get back to you later when my account password hopefully is recovered.

    • @cadethomas142
      @cadethomas142 Před 3 lety

      @Lewis Boston It worked and I actually got access to my account again. I'm so happy!
      Thank you so much, you really help me out :D

  • @joshuadelacruz3907
    @joshuadelacruz3907 Před 7 lety

    The tutorial is great and it is simple. I saw that you have CC textbox there but didn't used it. So, I want to ask if that is working for multiple email sending. Like I can input 5 email address at the CC textbox and send it. Please make us a tutorial. Thank you!

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, You can split email, and you can use foreach to send email. thanks

    • @santiepelayo6313
      @santiepelayo6313 Před 5 lety

      czcams.com/video/p5ZOHvIbYJc/video.html

  • @nickharris423
    @nickharris423 Před 7 lety

    Thank you very much... But I cant't open the project (I only can open the app).
    i USE c# 2010 is that the reason why? (Because you made it on a2013 edition). And, when I run the app, there's that 5.5.1 error (authentification)... Do you have any clues? do i have to add a line on the code? If yes, which one? I tried with 25th port and also 465 but still doesn't work
    Kind regards

  • @JS-nr5te
    @JS-nr5te Před 5 lety

    Hi!!
    It worked for me, thank you very much...
    Just one thing, if all textboxes are empty, how can I prevent an error that appears if I click send without any textbox filled?
    I hope you understand my question

  • @figenasil
    @figenasil Před 3 lety

    thanks a lot

  • @adulwahabkhan8543
    @adulwahabkhan8543 Před 7 lety

    Hello i want to send the email and sms to mutiple user which exist into the database using c# so Can u help me....

  • @nabeelsiddiqui5726
    @nabeelsiddiqui5726 Před 6 lety

    can u help . its giving an error. The specified string is not in the form required for an e-mail address. plz help

  • @abdulrahmanabdullah127

    this message was appeared to me "The SMTP host was not found"

  • @lucyacuna8876
    @lucyacuna8876 Před 7 lety

    In the textbox of the username, It is my user and password from my computer or from my email account?

  • @MamaEstaPresaPunk
    @MamaEstaPresaPunk Před 4 lety

    Perfect! 100%

  • @zkiat93
    @zkiat93 Před 7 lety

    Thanks a lot! It helps ;)

  • @JonathanIsmaila
    @JonathanIsmaila Před rokem

    What if I want to add an attachment to the email?

  • @elmanehmedov3308
    @elmanehmedov3308 Před 8 lety

    thank you,this is working ))

    • @foxlearn
      @foxlearn  Před 8 lety +1

      +Elman Ehmedov Thank you ^_^

  • @mzzdiscovery
    @mzzdiscovery Před 5 lety

    thanks alot but plz help me how to make it that i could be able to send mail to multy mail acount like using loop or a list of mails

    • @foxlearn
      @foxlearn  Před 5 lety

      OK. Thank you for your suggestion. I'll upload soon !

    • @mzzdiscovery
      @mzzdiscovery Před 5 lety +1

      @@foxlearn I'm waiting

  • @osamashahnawaz1528
    @osamashahnawaz1528 Před 7 lety

    Thanks it's works

  • @cryptojetsoftwaresolution9155

    Thanks...........

  • @johnbritto9950
    @johnbritto9950 Před 7 lety

    FormatExecption was unhandled: The Specified string is not in the form required for an email address.
    hi fox learn , am getting this error , can you please help me, i have followed every step of this tutorial , yet this error.

  • @tahakara2358
    @tahakara2358 Před 2 lety

    I can't allow less secure apps now.

  • @telladesina100
    @telladesina100 Před 5 lety

    please, I have an error saying, System.FormatException: 'An invalid character was found in the mail header: '@'.' please, I need the source code.

    • @foxlearn
      @foxlearn  Před 5 lety

      I think you miss something. Please check your code again. thank you !

  • @Dubswitcher
    @Dubswitcher Před 6 lety

    The string userstate = "Sending..."; command is causing it to throw an unknown command error.

  • @hridaysen1748
    @hridaysen1748 Před 4 lety

    hi, nice video but in mine says -"an invalid character was found in the mail header ". Can someone tell me what to do?

    • @foxlearn
      @foxlearn  Před 4 lety

      I think you miss something. Please check your code again. thank you !

  • @shaikashra8443
    @shaikashra8443 Před 7 lety +3

    Do we need internet connection for sending mail

    • @user-ov7sy8dx4g
      @user-ov7sy8dx4g Před 6 lety

      shaik ashar i followed the tutorial. when i click the send buttuon, it repeats sending several times. And i got many emails...T.T

    • @abdulwahabkhan6526
      @abdulwahabkhan6526 Před 6 lety +2

      NO :)

    • @Dubswitcher
      @Dubswitcher Před 6 lety +6

      This is the dumbest question I have ever seen at the top of a comment section.
      YES, you need a connection to send email. It's kind of a given.

    • @ahmedfares1284
      @ahmedfares1284 Před 6 lety

      not at all :')

    • @companionpuppy7539
      @companionpuppy7539 Před 5 lety

      nah just use ur magic wand

  •  Před 8 lety

    My Google account has two-step verification. Can I add something to that code to add the authorization key?

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, You need to turn on google service allows you to send an email via code. Thanks

  • @raphaelqueiroz7925
    @raphaelqueiroz7925 Před 8 lety

    How do I enable the sending mail feature on my GMAIL account ? I get the 5.5.1 error :/

    • @foxlearn
      @foxlearn  Před 8 lety

      +Raphaël Queiroz Hi, I showed how to activate Gmail allows you to send emails in this video. Thanks

  • @mariembenzineb4522
    @mariembenzineb4522 Před 5 lety +1

    Thank you so much sir , bless you

    • @foxlearn
      @foxlearn  Před 5 lety +2

      You're welcome. Thank you !

    • @HappyPlay-Play
      @HappyPlay-Play Před 5 lety +1

      your video inspire me so much, thank you

    • @3dgiftz
      @3dgiftz Před 2 lety +1

      @@foxlearn Thank you sir

  • @dailystudysupply9963
    @dailystudysupply9963 Před 7 lety

    still getting'
    Unable to connect to remote server
    Connection could not be made because the target machine actively refused it

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, You need to setting allow google send email, please check your code again. thanks

  • @muhammadhassaan262
    @muhammadhassaan262 Před 5 lety

    Hi.. can you tell me how to send customize email..Like change color or font size?

    • @foxlearn
      @foxlearn  Před 5 lety

      You need to send email with html format

    • @muhammadhassaan262
      @muhammadhassaan262 Před 5 lety

      @@foxlearn How can i do this using C# ?

    • @foxlearn
      @foxlearn  Před 5 lety +1

      For example
      msg = new MailMessage("xxxx@gmail.com",
      "yyyy@gmail.com", "Message",
      "This is test message" +
      "this is bold text !" +
      "This is some text !"
      );
      msg.IsBodyHtml = true;

  • @InFeCteDZC
    @InFeCteDZC Před 8 lety

    There Comes an error: Ein Ausnahmefehler des Typs "System.Reflection.TargetInvocationException" ist in mscorlib.dll aufgetreten.

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, Please check your code again. Make sure it's correct. thanks

    • @InFeCteDZC
      @InFeCteDZC Před 8 lety

      +Fox Learn maybe you can send me the Code per email: zerokeks@gmail.com, i dont Know where the Problem is

    • @foxlearn
      @foxlearn  Před 8 lety

      Sent. Thanks :)

  • @karenspania120
    @karenspania120 Před 8 lety

    hi, I got the error "The SMTP host was not found." What should i do ???

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi. What SMTP host are you using ? thanks

  • @deffog4rno
    @deffog4rno Před 3 lety

    WHAT SHOULD I TYPE IN THE USERNAME

    • @foxlearn
      @foxlearn  Před 3 lety

      Your user name mail

    • @deffog4rno
      @deffog4rno Před 3 lety

      @@foxlearn Can you give me an example please

  • @ikhlaqahmed6318
    @ikhlaqahmed6318 Před 8 lety

    I HAVE AN ERROR:
    The specified string is not in the form required for an e-mail address.
    can any one solve it?

    • @foxlearn
      @foxlearn  Před 8 lety

      +Ikhlaq Ahmed Hi, You need to register an account before playing. Thank you !

    • @shubhampande648
      @shubhampande648 Před 8 lety

      +Fox Learn Are you referring to Google Account? Thank you!

  • @ivodonckers25
    @ivodonckers25 Před 8 lety

    Its awesome, but need it with attachement !!!

    • @foxlearn
      @foxlearn  Před 8 lety

      +Ivo Donckers Hi, Thank you for your suggestion. I'll make the tutorial as soon as possible :)

  • @jlmercado6062
    @jlmercado6062 Před 7 lety

    Hi! I'm getting an error. It says that "The SMTP host was not found."

  • @coronakit
    @coronakit Před 6 lety

    can somebody send me code please? Very good tutorial

  • @adilkevin6220
    @adilkevin6220 Před 5 lety

    Please create video tutorial to receive e-mails also

    • @foxlearn
      @foxlearn  Před 5 lety

      You can view this video czcams.com/video/KFQGiOzNafQ/video.html . to know how to receive an email. Thank you !

  • @1ryqw989
    @1ryqw989 Před 4 lety

    line 34 is an error why ?

  • @larrym.williams2259
    @larrym.williams2259 Před 8 lety

    what will we write in username and password .. i am facing error in username and password ..

  • @tayyabarsalan8557
    @tayyabarsalan8557 Před 5 lety

    Code is working fine until or unless you add a reference on top
    using System.Web;
    then this code works.

  • @inframatic
    @inframatic Před 7 lety

    This is great but I am receiving an error.
    Would you kindly send me the source code so that I may compare? :D

  • @sardarmemon6842
    @sardarmemon6842 Před 11 měsíci

    plz give source file

  • @Hb-sl8xr
    @Hb-sl8xr Před 7 lety

    IS GIVE ME FAILURE SENDING MAIL PLEASE HELP ME I NEED IT FOR MAY PROJECT
    THANK YOU

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi. Which mail server are you sending? thanks

    • @Hb-sl8xr
      @Hb-sl8xr Před 7 lety +1

      stmp.live.com

    • @Hb-sl8xr
      @Hb-sl8xr Před 7 lety

      private void btnSend_Click(object sender, EventArgs e)
      {
      try
      {
      MailMessage mail = new MailMessage(txtFrom.Text, txtTo.Text, txtSubject.Text, textBox7.Text);
      SmtpClient client = new SmtpClient(txtSmtp.Text);
      client.Port = 465;
      client.Credentials = new System.Net.NetworkCredential(txtUsern.Text, txtPass.Text);
      client.EnableSsl = true;
      client.Send(mail);
      MessageBox.Show("mail sent", "success", MessageBoxButtons.OK);
      }
      catch (Exception ex)
      {
      MessageBox.Show(ex.Message);
      }

  • @anjibabupsr4160
    @anjibabupsr4160 Před 8 lety

    hai i m getting error, unable to connect remote server. plz get me solution

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, What mail server are you using ? thanks

    • @anjibabupsr4160
      @anjibabupsr4160 Před 8 lety

      I m using Gmail only, is there any other seetiings need to do. Thanks

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, You can go your gmail setting, then enable send email from your application. thanks

    • @anjibabupsr4160
      @anjibabupsr4160 Před 8 lety +1

      Hi, sry I didn't get you, in settings what I need to enable. can plz elaborate. thanks for your quick response

  • @sriharsha9958
    @sriharsha9958 Před 3 lety +1

    Sir plss send the code

    • @foxlearn
      @foxlearn  Před 3 lety

      Please do it or you can find code from my website

  • @testmail1445
    @testmail1445 Před 8 lety

    it's showing 5.5.1 authentication error :(

    • @foxlearn
      @foxlearn  Před 8 lety

      +Test Mail Hi, Please check your code again. Remember enable feature allows you send mail in Gmail config. Thank you !

  • @ilzrogacha3638
    @ilzrogacha3638 Před 4 lety

    May i have the source code? thanks.

  • @sofianeaboulfida9085
    @sofianeaboulfida9085 Před 7 lety

    How to send mail to multiple c # recipients
    pleas!!!!!!!!!!!!

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, You can use loop or add multiple address with ',' or ';' character

  • @NightTV
    @NightTV Před 7 lety

    give me the source code and how i will fix cs error?

    • @foxlearn
      @foxlearn  Před 7 lety

      What's your email? thank you

  • @mehranshafqat997
    @mehranshafqat997 Před 8 lety

    how to receive email ? in C# please make a tutorial on it :(

    • @foxlearn
      @foxlearn  Před 8 lety

      +mehran shafqat Hi, You can view czcams.com/video/KFQGiOzNafQ/video.html to know how to receive an email in C#. Thanks

    • @mehranshafqat997
      @mehranshafqat997 Před 8 lety

      with pop3 or imap ? receive email from gmail ?

    • @foxlearn
      @foxlearn  Před 8 lety

      +mehran shafqat Yes, That's right

    • @user-ul4es2vr2m
      @user-ul4es2vr2m Před 4 lety

      @@mehranshafqat997 pop3 or imap? Yes that's right))))

  • @mongii2
    @mongii2 Před 3 lety

    Your voice was different a little from now.

  • @shivkumar-hh5tk
    @shivkumar-hh5tk Před 7 lety

    hai, I am getting the error. Can U send me the code

  • @dydo2331
    @dydo2331 Před 3 lety

    What's your password ?

  • @yeakleang
    @yeakleang Před 7 lety

    Who the hell is Lucy in MailAddress?

    • @foxlearn
      @foxlearn  Před 7 lety

      Your email, you can change your name

  • @DavidStefan-nz2en
    @DavidStefan-nz2en Před 7 lety

    can you please send me the code?

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, What's your email? thanks

  • @carisaputri4658
    @carisaputri4658 Před 7 lety

    from ?? error

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, What error are you getting? Thank you

  • @user-ul4es2vr2m
    @user-ul4es2vr2m Před 4 lety

    I put the 333th like

  • @rinnesm7419
    @rinnesm7419 Před 6 lety

    How do we get username and password ?

    • @foxlearn
      @foxlearn  Před 6 lety

      You should create a gmail account, then you can play demo. Thank you !

    • @rinnesm7419
      @rinnesm7419 Před 6 lety

      @@foxlearn ah I see. Thank you so much for your respond.
      But then I get an erorr when I click button Send :
      "The SMTP connection resquires a secure connection or the client was not authorized".
      What should I do ?

    • @foxlearn
      @foxlearn  Před 6 lety

      Which mail server are you using? gmail, yahoo...etc. You can post your question at c-sharpcode.com .I'll try to answer as soon as possible. Thank you !

    • @rinnesm7419
      @rinnesm7419 Před 5 lety

      @@foxlearn I've post my question just now. Could you please check it and help me :D

  • @innadipus4123
    @innadipus4123 Před 7 lety

    Can you send the codes? thank u

    • @foxlearn
      @foxlearn  Před 7 lety

      Hi, What's your email? Thanks

    • @innadipus4123
      @innadipus4123 Před 7 lety

      Fox Learn kathleenortega1002@yahoo.com.ph thank you!

  • @user-hp6to2zi4v
    @user-hp6to2zi4v Před 8 lety

    username and password ?

    • @foxlearn
      @foxlearn  Před 8 lety

      Hi, You can use www.watools.es/ to generate a whatsapp account. Thanks

  • @whatYouMustKnowInShs
    @whatYouMustKnowInShs Před 9 lety +2

    is given me error 5.5.1

    • @foxlearn
      @foxlearn  Před 9 lety

      +samuel boateng What's your mail server name ? yahoo, google...?

    • @whatYouMustKnowInShs
      @whatYouMustKnowInShs Před 9 lety

      google

    • @foxlearn
      @foxlearn  Před 9 lety

      +samuel boateng Have you enabled google allow send email ?

    • @whatYouMustKnowInShs
      @whatYouMustKnowInShs Před 9 lety

      how is it done ?
      i did allow insecure apps to send messages thought.

    • @foxlearn
      @foxlearn  Před 9 lety

      +samuel boateng Hi, Please make sure your code is correct, check your port again