|
That would depend on what it's doing and what you expect it to do!
Or were we just supposed to read your mind?
|
|
|
|
|
So you modified your post and we are still supposed to guess what is not working and what you expect it do?Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
|
Off the top of my head, I'd guess you're missing a break; statement after setting FormLoaded to true .
/ravi
|
|
|
|
|
You Should First Compile it and Send the error message IF generate. Else Debug it Line By Line.
Best RegardIf you can think then I Can.
|
|
|
|
|
There are many ways to achieve a single instance form, and I suspect that the problem you are having is that the form name you are searching for doesn't exist in the OwnedForms collection."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
It looks like you might be missing a form in your loop.
DybsThe shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Hi,
I developed a simple application with C#, using the VSTO 2008 tools.
It is supposed to be used a mass-mailing item from Outlook 2007.
All it does is taking the mail recipients from the "To", "CC" & "BCC" and filter out the addresses which are either invalid or marked as non-subscribers. (There is a DB which stores all the email addresses)
The problem is not the logic inside, it works fine.
When the method is complete, the outlook starts to go crazy:
The icons at the bottom system tray flickers, CPU soars to 100% and the mail is stuck in the outbox.
Sometimes I can see the "Outlook is synchronizing folders".
Has anyone got the clue why is it happening?
I am attaching some of my code:
namespace SMOutlook2007AddIn
{
public partial class ThisAddIn
{
private Outlook.Application App = new Outlook.Application();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
if (string.IsNullOrEmpty(ACCOUNT_NAME))
{
MessageBox.Show("Couldn't Load SM Addin.\n No ACCOUNT_NAME in config file.");
}
else
{
App.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(App_ItemSend);
}
}
private static ICollection<string> GetEmailsList(AddressEntry addressEntry)
{
if (addressEntry.DisplayType == OlDisplayType.olUser)
{
return new string[] { addressEntry.Address };
}
if (addressEntry.DisplayType != OlDisplayType.olPrivateDistList)
{
throw new System.Exception("Unknown Recipient Type " + addressEntry.DisplayType + "\nRecipient Name: " + addressEntry.Name);
}
if (addressEntry.Members == null || addressEntry.Members.Count == 0)
{
return new string[0];
}
List<string> addresses = new List<string>();
foreach (AddressEntry entry in addressEntry.Members)
{
addresses.AddRange(GetEmailsList(entry));
}
return addresses;
}
private static List<string> GetInvalidEmails(List<string> Emails)
{
if (Emails == null || Emails.Count == 0)
{
return null;
}
StringBuilder emailsList = new StringBuilder();
for (int i = 0; i < Emails.Count; i++)
{
emailsList.AppendFormat("'{0}'", Emails[i]);
if (i != Emails.Count - 1)
{
emailsList.Append(",");
}
}
List<string> invalidEmails = new List<string>();
string queryString = QUERY.Replace("{0}", emailsList.ToString().Replace("''","'"));
SqlCommand cmd = new SqlCommand();
cmd.CommandText = queryString;
cmd.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["StrongMail"].ConnectionString);
SqlDataReader dataReader = null;
try
{
cmd.Connection.Open();
dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
invalidEmails.Add(dataReader["Email"].ToString());
}
}
finally
{
if (dataReader != null && !dataReader.IsClosed)
{
dataReader.Close();
}
if (cmd.Connection.State == ConnectionState.Open)
{
cmd.Connection.Close();
}
}
return invalidEmails;
}
void App_ItemSend(object Item, ref bool Cancel)
{
Outlook.MailItem Mail = (Outlook.MailItem)Item;
if (!Mail.SendUsingAccount.DisplayName.Equals(ACCOUNT_NAME, StringComparison.OrdinalIgnoreCase))
{
return;
}
string[] toArray =
Mail.To == null ? new string[] { } : Mail.To.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] ccArray =
Mail.CC == null ? new string[] { } : Mail.CC.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
string[] bccArray =
Mail.BCC == null ? new string[] { } : Mail.BCC.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
Dictionary<string, Recipient> toDic = new Dictionary<string, Recipient>();
Dictionary<string, Recipient> ccDic = new Dictionary<string, Recipient>();
Dictionary<string, Recipient> bccDic = new Dictionary<string, Recipient>();
List<string> emailToCheck = new List<string>();
List<string> invalidEmails = null;
for (int i = 0; i < toArray.Length; i++)
{
toArray[i] = toArray[i].Replace(" ", "");
}
for (int i = 0; i < ccArray.Length; i++)
{
ccArray[i] = ccArray[i].Replace(" ", "");
}
for (int i = 0; i < bccArray.Length; i++)
{
bccArray[i] = bccArray[i].Replace(" ", "");
}
try
{
while (Mail.Recipients.Count > 0)
{
Recipient rec = Mail.Recipients[1];
Mail.Recipients.Remove(1);
List<Recipient> recList = new List<Recipient>();
ICollection<string> emailList = GetEmailsList(rec.AddressEntry);
foreach (string email in emailList)
{
Recipient newRec = Mail.Session.CreateRecipient(email);
if (!newRec.Resolve())
{
continue;
}
recList.Add(newRec);
if (!emailToCheck.Contains(newRec.Address))
{
emailToCheck.Add(newRec.Address);
}
}
if (Array.IndexOf(toArray, rec.Name) >= 0)
{
foreach (Recipient r in recList)
{
toDic[r.Address.ToLower()] = r;
}
}
if (Array.IndexOf(ccArray, rec.Name) >= 0)
{
foreach (Recipient r in recList)
{
ccDic[r.Address.ToLower()] = r;
}
}
if (Array.IndexOf(bccArray, rec.Name) >= 0)
{
foreach (Recipient r in recList)
{
bccDic[r.Address.ToLower()] = r;
}
}
}
invalidEmails = GetInvalidEmails(emailToCheck);
}
catch (System.Exception e)
{
Cancel = true;
MessageBox.Show(e.Message + "\nMailing Canceled", "Error Validating Emails");
return;
}
StringBuilder toList = new StringBuilder();
StringBuilder ccList = new StringBuilder();
StringBuilder bccList = new StringBuilder();
foreach (KeyValuePair<string, Recipient> kvp in toDic)
{
if (invalidEmails == null || !invalidEmails.Contains(kvp.Key.Replace("'", "")))
{
toList.AppendFormat("{0};", kvp.Key);
}
}
foreach (KeyValuePair<string, Recipient> kvp in ccDic)
{
if (invalidEmails == null || !invalidEmails.Contains(kvp.Key.Replace("'", "")))
{
ccList.AppendFormat("{0};", kvp.Key);
}
}
foreach (KeyValuePair<string, Recipient> kvp in bccDic)
{
if (invalidEmails == null || !invalidEmails.Contains(kvp.Key.Replace("'", "")))
{
bccList.AppendFormat("{0};", kvp.Key);
}
}
if (toList.Length == 0 && ccList.Length == 0 && bccList.Length == 0)
{
MessageBox.Show("All recipients addresses are invalid or unsubscribed.\nSend operation aborted.");
Cancel = true;
return;
}
Mail.To = null;
Mail.CC = null;
Mail.BCC = null;
if (toList.Length > 0)
{
Mail.To = toList.ToString().Substring(0, toList.Length - 1);
}
if (ccList.Length > 0)
{
Mail.CC = ccList.ToString().Substring(0, ccList.Length - 1);
}
if (bccList.Length > 0)
{
Mail.BCC = bccList.ToString().Substring(0, bccList.Length - 1);
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { }
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
|
|
|
|
|
Do you know that your message contains 4.3479162 KiloMeters of characters?
And that it is unformated => hard to read?
|
|
|
|
|
unformatted ==> ignored.
|
|
|
|
|
To expand on what Luc said,
A ton of code and unformmated = ignored.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hello,
I want to ask maybe somebody know.
How I Append String To Excel File????????
I have a command for that?Like "File.AppendAllText(stringfile,stringtoappend);"!!
ThankYou.
|
|
|
|
|
1) you can use OleDB
2) use interop
Here's one of many articles on that topic
|
|
|
|
|
I dont have a simple way to do that?
|
|
|
|
|
Nope. Sure there are some comercial apps that ease the process but not as simple as
stream.Write(..);
|
|
|
|
|
Here you go again. Sure as sh*t, somebody's told you that you have to do something more complicated than Console.WriteLine("Hello World"); and off you go whinging about it. Grow yourself some balls and actually try some of the advice you've been given."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You have asked this question multiple times and have been told you must use interop to accomplish the task you are asking for I know the language. I've read a book. - _Madmatt
|
|
|
|
|
No matter how many times you ask this question, the answer will NOT change. You were told what you had to do back here[^].
|
|
|
|
|
noamtzu00 wrote: File.AppendAllText
So how many times are you going to ask this question before you figure out that you might actually have to work for it? You have been given the answer and you could have probably done it by now instead of asking the same question over and over.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
How can textbox control to set the money format for input?
I try to use cultureInfo but it doesn't work.
System.Globalization.CultureInfo cultur = new System.Globalization.CultureInfo("fa-IR");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(cultur);
|
|
|
|
|
the text box doesn't do any automatically formats for the string/values.
Format the string using string.Format() and then set the text to the text box.
Or use a masked text box with a custom mask or...
or something like:
System.Globalization.CultureInfo cultur = new System.Globalization.CultureInfo("fa-IR");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(cultur);
decimal moneyvalue = 1921.39m;
txextBox1.Text = String.Format("{0:C}", moneyvalue);
|
|
|
|
|
I think you suggest string.format("C").
but my language is Persian and it's not for foreign language.
|
|
|
|
|
I don't know about persian but
if in UK => £9.99
in USA => $9.99.
in Euro Countryies => 9.99 €
in romania => 9.99 RON
if it doesn't work create a custom string.format();
|
|
|
|
|
Hi, I have a basic enough problem with implementing inheritance in an interface.
Here is an example of what I would LIKE to do:
static void Main(string[] args)
{
List<ISuperString> myStrings = new List<ISuperString>();
myStrings.Add(...SOMETHING...);
Console.WriteLine(myStrings[0].containsCapitalLetters());
Console.WriteLine(myStrings[0].ToLower());
}
public interface ISuperString : string
{
bool containsCapitalLetters();
}
I have seen (and implemented) some workarounds for this, however they are a bit messy for my taste.
Basically, is it possible to either have an interface inherit from a class or to derive an interface from a class (i.e. an IString interface)?
thanks
|
|
|
|
|
What I think you really want is an extension method.
public class ExtensionMethods
{
public static bool ContainsCapitalLetters(this String)
{
bool result = false;
return result;
}
}
Usage would be
String myString = "AbcdefG";
bool containsCapitalLetters = myString.ContainsCapitalLetters(); .45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|