CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: CC and BCC not working in SMTP

  1. #1
    Join Date
    Sep 2014

    CC and BCC not working in SMTP


    In the Webmaster's inbox, I can see:

    From: Sender's email address
    To: Webmaster's email address
    CC: Assistant Webmaster's address

    But the sender does not receive a copy of his own message in his own inbox and nor does the Assistant Webmaster. In other words, neither the CC or BCC is working correctly. The Subject does not show up either in the Webmaster's email.

    This is the relevant code from my SMTP:

    Protected Sub SendEmail_Click(sender As Object, e As System.EventArgs)
            Dim myMessage As New MailMessage
            Dim Smtpserver As New SmtpClient
                Dim user_name As String = Request.Form("user_name")
                Dim user_email As String = Request.Form("user_email")
                Dim user_subject As String = Request.Form("user_subject")
                Dim user_message As String = Request.Form("user_message")
                Dim CC As MailAddress = New MailAddress("")
                Dim Bcc As MailAddress = New MailAddress(user_email)
                myMessage.From = New MailAddress(user_email) 'User's email
                myMessage.To.Add(New MailAddress("")) 'Webmaster
                myMessage.Subject = user_subject
                myMessage.Body = user_message
    What am I doing wrong, please?


  2. #2
    Join Date
    Dec 2018

    Re: CC and BCC not working in SMTP

    public static void Email_With_CCandBCC(String ToEmail,string cc,string bcc, String Subj, string Message)
            //Reading sender Email credential from web.config file
            HostAdd = ConfigurationManager.AppSettings["Host"].ToString();
            FromEmailid = ConfigurationManager.AppSettings["FromMail"].ToString();
            = ConfigurationManager.AppSettings["word"].ToString();
            //creating the object of MailMessage
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(FromEmailid); //From Email Id
            mailMessage.Subject = Subj; //Subject of Email
            mailMessage.Body = Message; //body or message of Email
            mailMessage.IsBodyHtml = true;
            mailMessage.To.Add(new MailAddress(ToEmail)); //receiver's TO Email Id
            mailMessage.CC.Add(new MailAddress(cc)); //Adding CC email Id
            mailMessage.Bcc.Add(new MailAddress(bcc));  //Adding BCC email Id
            SmtpClient smtp = new SmtpClient();  // creating object of smptpclient
            smtp.Host = HostAdd;              //host of emailaddress for example etc
            //network and security related credentials
            smtp.EnableSsl = true;
            NetworkCredential NetworkCred = new NetworkCredential();
            NetworkCred.UserName = mailMessage.From.Address;
            NetworkCred.word = ;
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = NetworkCred;
            smtp.Port = 587;
            smtp.Send(mailMessage); //sending Email
    Last edited by 2kaud; December 28th, 2018 at 08:09 AM. Reason: Added code tags

  3. #3
    Join Date
    Sep 2014

    Re: CC and BCC not working in SMTP

    Many thanks for your reply, vedikaledange

    I will need to customise your code a little but it's looking impressive.

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)