Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8756595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:07:08+00:00 2026-06-13T14:07:08+00:00

I am working on a WinForm where a reportviewer is embedded. How do I

  • 0

I am working on a WinForm where a reportviewer is embedded.

How do I send email via gmail/yahoo and attach this report as a pdf?
I looked at this post
http://www.codeproject.com/Articles/32109/Send-Mail-and-Print-Report-in-Report-Viewer-Contro but was not sure if it would work only with desktop email clients such as Outlook or will it support web based email client?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:07:10+00:00Added an answer on June 13, 2026 at 2:07 pm
    const string HTML_TAG_PATTERN = "<.*?>";
    static string StripHTML(string inputString)
    {
      return Regex.Replace(inputString, HTML_TAG_PATTERN, string.Empty);
    }
    
    public static void sendMessage()
    {
      var username = "john.doe@gmail.com";
      var password = "password";
      MailAddress MailFrom = new MailAddress("john.doe@gmail.com");
      MailAddress MailTo = new MailAddress("john.doe@gmail.com");
      var subject = "TEST SUBJECT";
      var attachmentPath = "test.pdf";
      var mailBody = "<b>test</b>";
    
    
      NetworkCredential cred = new NetworkCredential(username, password);
    
      System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
      smtp.Host = "smtp.gmail.com";
      smtp.UseDefaultCredentials = false;
      smtp.EnableSsl = true;
      smtp.Credentials = cred;
      smtp.Port = 587;
    
      MailMessage mail = new MailMessage();
    
      mail.IsBodyHtml = true;
    
      AlternateView avAlternateView = null;
      Encoding myEncoding = Encoding.GetEncoding("UTF-8");
    
      avAlternateView = AlternateView.CreateAlternateViewFromString(StripHTML(mailBody), myEncoding, "text/plain");
      mail.AlternateViews.Add(avAlternateView);
    
      avAlternateView = AlternateView.CreateAlternateViewFromString(mailBody, myEncoding, "text/html");
      mail.AlternateViews.Add(avAlternateView);
    
      mail.Sender = MailFrom;
      mail.From = MailFrom;
      mail.ReplyTo = MailFrom;
    
      mail.To.Add(MailTo);
    
      mail.Subject = subject;
      mail.SubjectEncoding = Encoding.GetEncoding("UTF-8"); 
    
      mail.BodyEncoding = Encoding.GetEncoding("UTF-8");
    
      Attachment attachment = new Attachment(attachmentPath);
      mail.Attachments.Add(attachment);
      try
      {
        smtp.Send(mail);
      }
      catch (Exception ex)
      {
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VS2010, working on a WinForms application that uses the ReportViewer control
I am working on a C# WinForm application in Visual Studio 2008 and are
I am working on a C# WinForm application in Visual Studio 2008. I have
I am working on a little WinForm app and have been trying to find
I'm working with an ActiveX control placed on a winform. I'd when the user
I'm working with a WinForms app. I have an RDLC report that will be
My winform window was working fine then i added a combobox to it. Now
I'm working on an rather small application (C#, winform) that is kind of front-end
I'm having some serious issues with a WinForm application that I'm working on. Currently,
I want to pass myConnString in all forms. ( I am working in winform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.