• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Console Program VB.NET

Hello experts,

I have created a vb.net console program (visual studio 2010) that basically takes alert messages from an ms outlook folder and parses the data from the messages in the outlook folder, takes the parsed data and puts in into a csv file and sends the csv file off as an email. The program runs with no issues on my development machine, however when I try and place the .exe on the machine I need to run it on it does not send out the email. I receive the following error in the cmd window.

Unhandled exception: system.argumentsnullexception: Value cannot be null
Parameter name: addresses
at system.net.mail.mailaddresscollection.add(string addresses)
at conelitereorderalerts.modmain.fnmailer(string strattachment)
at con elitereorderalerts.modmain.main

I also tried on another test machine and receive the same error. I get the click here for windows to find a solution but of course nothing happens. Any assistance would be great. Please let me know if I need to provide more detail
0
tmaususer
Asked:
tmaususer
  • 2
  • 2
1 Solution
 
Lokesh B RDeveloperCommented:
Hi,

NullException: It clearly says that something is NULL,  i.e address

You need add more conditions to check if anything is NULL and write the error in log.
0
 
tmaususerAuthor Commented:
I agree but don't know what or why. I have everything set identical on my test machine so that is what is puzzling to me. I am not a programmer so it will take me some time to figure out how to write to an error log.
0
 
Lokesh B RDeveloperCommented:
Hi,

Ahhhh ok.

I think some value is no available in the test machine as it is in the DEV machine.

You can write log file as below.

Log method

public void WriteLog(string message)
{
        using (StreamWriter sWriter = new StreamWriter("D\log.dat", true))
                {
                    using (TextWriter tWriter = TextWriter.Synchronized(sWriter))
                    {
                        ErrorMessage = string.Format("{0:MM/dd/yyy hh:mm:ss.fff tt} :: Application:: - {1}", DateTime.Now, message);
                        tWriter.WriteLine(ErrorMessage);
                    }
                }
}

Open in new window


In Program

if(email != null)
{
    // do the work
}
else
{
    WriteLog("Email is NULL");
}

Open in new window

0
 
tmaususerAuthor Commented:
Ok thanks. I will give it a shot and report back
0
 
glnjalsaCommented:
can anyone give  me program in vb.net console where timer start when program starts and after it ends the timer calculates the time of the program executed like ( a loop starts and ends so start time - endtime)
this time is displayed by the timer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now