Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. send mail with format

send mail with format

Scheduled Pinned Locked Moved ASP.NET
toolstutorialhtmldatabasecom
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    padmanabhan N
    wrote on last edited by
    #1

    Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
    or

    because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

    Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

    J S N T E 5 Replies Last reply
    0
    • P padmanabhan N

      Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
      or

      because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

      Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

      J Offline
      J Offline
      JHizzle
      wrote on last edited by
      #2

      have you tried HTMLEncode on the string you get back?

      1 Reply Last reply
      0
      • P padmanabhan N

        Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
        or

        because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

        Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

        S Offline
        S Offline
        Sneha Bisht
        wrote on last edited by
        #3

        string message =""; message=""+ "" + "

        UserName:

        your username text

        Password:

        your password

        "; Try like this .............

        P 1 Reply Last reply
        0
        • P padmanabhan N

          Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
          or

          because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

          Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          If you are using HTMLFormat you need to supply HTML format, you know, like in a webpage.


          I know the language. I've read a book. - _Madmatt

          P 1 Reply Last reply
          0
          • N Not Active

            If you are using HTMLFormat you need to supply HTML format, you know, like in a webpage.


            I know the language. I've read a book. - _Madmatt

            P Offline
            P Offline
            padmanabhan N
            wrote on last edited by
            #5

            thanks for your reply, actually i too have formatted but the values are editable by the end user. They can give any type of words.......

            Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

            N 1 Reply Last reply
            0
            • S Sneha Bisht

              string message =""; message=""+ "" + "

              UserName:

              your username text

              Password:

              your password

              "; Try like this .............

              P Offline
              P Offline
              padmanabhan N
              wrote on last edited by
              #6

              actually i too have formatted but the values are editable by the end user. They can give any type of words.......

              Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

              1 Reply Last reply
              0
              • P padmanabhan N

                thanks for your reply, actually i too have formatted but the values are editable by the end user. They can give any type of words.......

                Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #7

                Then you'll need to come up with a parsing engine to format the input appropriately.


                I know the language. I've read a book. - _Madmatt

                P 1 Reply Last reply
                0
                • N Not Active

                  Then you'll need to come up with a parsing engine to format the input appropriately.


                  I know the language. I've read a book. - _Madmatt

                  P Offline
                  P Offline
                  padmanabhan N
                  wrote on last edited by
                  #8

                  can you just explain in detail

                  Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                  N 1 Reply Last reply
                  0
                  • P padmanabhan N

                    can you just explain in detail

                    Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #9

                    If you want me to do the work, then contact me and we'll discuss rates


                    I know the language. I've read a book. - _Madmatt

                    1 Reply Last reply
                    0
                    • P padmanabhan N

                      Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
                      or

                      because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

                      Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                      T Offline
                      T Offline
                      T M Gray
                      wrote on last edited by
                      #10

                      string msgBody = string.Format(@"Hi,

                      This is the format of Username and Password

                      UserName : {0}
                      Password : {1}
                      ",yourUserNameVariable, yourPasswordVariable);

                      If you are saying the users can change the entire message (probably a bad idea) then you need to come up with some formatting engine somewhat like these forums where you can insert certain codes to get smileys or other formatting things.

                      1 Reply Last reply
                      0
                      • P padmanabhan N

                        Hi experts, I am retriving few values which is stored in database like, ----------------------------------------------- Hi, This is the format of Username and Password UserName : xyz Password : *** Regards, ------------------------------------------------ but when email is sent it comes as, ------------------------------------------------ Hi,This is the format of Username and Password UserName : xyzPassword : *** Regards, ------------------------------------------------ how to send mail like the original format. i can't include
                        or

                        because this content is changable. i have also tried "mailMsg.BodyFormat = MailFormat.Html; " Please guide me......

                        Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                        E Offline
                        E Offline
                        Eaverae
                        wrote on last edited by
                        #11

                        padmanabhan N wrote:

                        i have also tried "mailMsg.BodyFormat = MailFormat.Html; "

                        You may have tried this, but did you include some HTML tags in your code as well? Because just saying it should be HTML doesn't make it HTML in a flash, you'll need to code your text in HTML. IE: Let's say you username variable is a string _username, and you password is a string _password. Then try the following (in asp.net/c#): On top of your page:

                        using System.Net.Mail

                        then in your SendMail method:

                        private void SendMail(string _username, string _password)
                        {
                        string MailBody = "Hi,

                        This is the format of Username and Password

                        UserName : " + _username + "
                        ";
                        MailBody += "Password : " + _password + "

                        Regards,";
                        MailMessage MMsg = new MailMessage();
                        MMsg.From = new MailAddress("youmailadress@youmailprovider.com");
                        MMsg.To.Add(new MailAddress("therecievingadress@therecievingdomain.com"));
                        MMsg.Subject = "Your subject";
                        MMsg.IsBodyHtml = true; //This is what makes your e-mail HTML formatted.
                        MMsg.Body = MailBody; //The content of your e-mail
                        SmtpClient SMTPSender = new SmtpClient();
                        SMTPSender.Host = "your mailhost"; //this is often "localhost"
                        SMTPSender.Send(MMsg);
                        }

                        Hope this helps.

                        "My personality is not represented by my hometown."

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups