Wont send mail and start Outlook again ?

  • Thread starter Thread starter Ksor2
  • Start date Start date
K

Ksor2

Guest
I have build a little program for the scheduler in Window 10 so that every Sunday at noon different tasks will happen:



1) my Outlook will shut down,

2) my outlook.pst file is copied to my NASDrive,

3) a mail is send to me with the result ... DONE / NOT DONE !

4) Outlook is started again

I use the program for me (KS) on my machine and my wife (TS) on her machine. Our initials is used to send the mail to theright mail address.

Here is some snips from my code - first the overall :

try {
readTheArguments(args);
if (args[0]=="KS" | args[0]=="TS") {
Boolean HuskStartOutlook=false;
if (ThisIsRunning("Outlook")) {
StopExecutionOf("Outlook");
HuskStartOutlook =true;
}
File.Copy(fra , til, true);
sendMail(mailModtager);
if (HuskStartOutlook==true) {
ProcessStartInfo startInfo = new ProcessStartInfo("Outlook.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
}
}
}
catch {
sendFailMail(mailModtager);
}


And here are the code for sending the mail - my credentials XXXX YYYY of cause:

private static void sendMail(String Til) {
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("Support@KS.NET");
mail.To.Add(Til);
mail.Subject = "Sikkerhedskopiering af Outlook";
mail.Body = "Der er netop nu:" +Environment.NewLine+Environment.NewLine+
DateTime.Now +Environment.NewLine+Environment.NewLine+
"afsluttet en sikkerhedskopiering af din Outlook."+Environment.NewLine+Environment.NewLine+
"Kan du fremadrettet have en fortsat god dag !"+Environment.NewLine+Environment.NewLine+
"Venlig hilsen"+Environment.NewLine+
"TeamSupport";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential(XXXX, YYYY);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
}


The program had worked for years and still do on MY machine but NOT all of it on my wifes machine.

On her machine 1) and 2) is done but 3) and 4) is NOT done !

I can see on MY GMAIL account that the mail for ME is in the folder "Send mails" but none for my wife !

Any ideas where to look for the problems - remember it DID RUN for BOTH of us some month back ?

Continue reading...
 
Back
Top