|
Hello Dave Kreskowiak,
I agreed with you. but i'm talking about those mails which come to me when my outlook is not running and as i run my outlook i got all mails in my outlook but i wonder on which event i can call my WCF service method to get those mails
Thanks
|
|
|
|
|
There is no seperate event.
All new emails that come into the client will raise the exact same event, no matter if they show up when Outlook starts or not.
The problem is that your Add-In may not have wired up the event handlers before that happens. Add-Ins are loaded before Outlook checks with the mail servers to pickup mail, but it doesn't wait for each Add-In to completely load and initialize itself. You have to make sure that one of the first things you do is wire up the events you want and don't take forever to init your code.
|
|
|
|
|
I have a stream object containing html that I can read as a List<Char>. The stream contains html. What I need to do is convert the stream of html into xml and store the xml into a xmlDocument in C#. Can anyone show me some code that will help me do this?
Thanks,
Steve Holdorf
|
|
|
|
|
Please explain what do you mean by "convert html to xml". Both are just strings wiht set format, but there are many cases that valid html is not valid xml (for example <br> and <p> tags may be not terminated)
You can try to parse the html and try to "fix" it, but it may not be worth the effort.
On the other hand if you have control over the html and can ensure correct structure yourself, nothing prvents you from creating XmlDocument out of it using Load() or LoadXml() methods.
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
What I mean is that I am reading excel spreadsheet cells pasted into an editor and pulling the content of the editor into a stream of html. Next, what I want to dso is take the html stream and make it into an XML stream that I can load into an XMLDocument (ie <table .. ></table> into <table>......<table>) then I will parse the xml data and store it into the database.
Thanks,
Steve Holdorf
|
|
|
|
|
You'll need to use something like the HTML Agility Pack[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard,
The codeplex library is great. One question; however. It's class object works by writting the html to a file on the server then the app code must read the file back into an xmldocument. Because of security reasons we can't allow the application to save a file from the browser to the server and then read it back from the server. Is there anyway to have the html to xml converter class write the converted html to a stream or some thing else besides a file on the server?
Thanks a lot!!!!!
Steve Holdorf
|
|
|
|
|
As well as the overloads of the Load method which take a file path, there are overloads which take a Stream or a TextReader as the source:
- File path:
void Load(string) void Load(string, bool) void Load(string, Encoding) void Load(string, Encoding, bool) void Load(string, Encoding, bool, int)
- Stream:
void Load(Stream) void Load(Stream, bool) void Load(Stream, Encoding) void Load(Stream, Encoding, bool) void Load(Stream, Encoding, bool, int)
void Load(TextReader)
There's also a LoadHtml method which accepts a string containing the HTML to load.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Goodmorning to all!
Ehm i want create a button ribbon and when i press it load a windows form integrated into outlook 2010 or 2007 or 2013 (if it exited from building). Ehm i started creating button ribbon with this guide:
http://blogs.msdn.com/b/mcsuksoldev/archive/2010/07/12/building-and-deploying-an-outlook-2010-add-in-part-1-of-2.aspx
When i press it i would load a form into outlook that load all contacts of my public folder with this name "Contatti Itech" into a datagrid view.
How can i do it?
Plz help me!
Thanks for any help! Code are appreciated too!!!
Ehm i forgot one thing:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Reflection;
using System.Diagnostics;
namespace OutlookInteropSample
{
public partial class MainForm : Form
{
private ToolTip contactToolTip = new ToolTip();
private Outlook.MAPIFolder oContactsFolder = null;
public MainForm()
{
InitializeComponent();
}
private void buttonGetContacts_Click(object sender, EventArgs e)
{
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
oContactsFolder = oNS.GetFolderFromID("000000001A447390AA6611CD9BC800AA002FC45A0300D4985F464F07654AA9CA8D6B785E166E000000004E3B0000", Type.Missing);
Console.WriteLine(oContactsFolder.EntryID);
getContacts(oContactsFolder);
oApp = null;
oNS = null;
}
private void ChiamaFunzia()
{
}
private void listViewContacts_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
{
contactToolTip.SetToolTip((Control)listViewContacts, getContactInfo((ListViewItem)e.Item));
contactToolTip.Active = true;
}
private void getContacts(Outlook.MAPIFolder oContacts)
{
try
{
listViewContacts.Items.Clear();
string filter = "[MessageClass] = \"IPM.Contact\"";
Outlook.Items oContactItems = oContacts.Items.Restrict(filter);
foreach (Outlook.ContactItem oContact in oContactItems)
{
try
{
ListViewItem item = new ListViewItem();
item.Text = oContact.Email1DisplayName;
item.Tag = oContact;
this.listViewContacts.Items.Add(item);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
oContactItems = null;
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString(), this.Name);
}
finally
{
this.listViewContacts.EndUpdate();
}
if (this.listViewContacts.Items.Count > 0)
{
this.buttonSendEmail.Enabled = true;
}
else
{
this.buttonSendEmail.Enabled = false;
}
}
private string getContactInfo(ListViewItem contact)
{
Outlook.ContactItem oContact = (Outlook.ContactItem)contact.Tag;
StringBuilder sb = new StringBuilder();
if (oContact.CompanyName != null && oContact.CompanyName.Length > 0) sb.AppendLine("Archivia come: " + oContact.CompanyName);
oContact = null;
return sb.ToString();
}
private void listViewContacts_MouseLeave(object sender, EventArgs e)
{
contactToolTip.Active = false;
}
private void listViewContacts_DoubleClick(object sender, EventArgs e)
{
ListViewItem activeItem = ((ListView)sender).SelectedItems[0];
if (activeItem != null)
{
Outlook.ContactItem oContact = (Outlook.ContactItem)activeItem.Tag;
EditContact editBox = new EditContact(oContact);
oContact = null;
if (editBox.ShowDialog() == DialogResult.OK)
{
getContacts(oContactsFolder);
}
}
}
private void buttonSendEmail_Click(object sender, EventArgs e)
{
Outlook.Application oApp = new Outlook.Application();
if (this.listViewContacts.SelectedItems != null &&
this.listViewContacts.SelectedItems.Count > 0)
{
Outlook.ContactItem oRecip = (Outlook.ContactItem)(this.listViewContacts.SelectedItems[0].Tag);
Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem));
email.Recipients.Add(oRecip.Email1Address);
email.Subject = "Just wanted to say...";
email.Body = "Have a great day!";
if (MessageBox.Show("Are you sure you want to send a good day message to " + oRecip.Email1DisplayName + "?", "Send?", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
try
{
((Outlook.MailItem)email).Send();
MessageBox.Show("Email sent successfully.", "Sent");
}
catch (Exception ex)
{
MessageBox.Show("Email failed: " + ex.Message, "Failed Send");
}
}
oRecip = null;
email = null;
}
}
private void MainForm_Load(object sender, EventArgs e)
{
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
oContactsFolder = oNS.PickFolder();
getContacts(oContactsFolder);
oApp = null;
oNS = null;
}
}
}
The long string [000000001A447390AA6611CD9BC800AA002FC45A0300D4985F464F07654AA9CA8D6B785E166E000000004E3B0000] is id for my public folder. Is there anyway to get public folder by name such as "Contatti Itech"?
Thanks again!
modified 8-Nov-12 4:54am.
|
|
|
|
|
I am trying to convert the string to datetime including the milliseconds... unfortunately when I used the Convert.ToDateTime method, it does not return the milliseconds... I have tried the parse and parseExact method in the Datetime and DateTimeOffset classes as well... none of them returning the milliseconds... I read the previous discussion regarding this issue and none of the solutions return the milliseconds...This is what I am trying to do:
string strDate = '2012-11-08 08:42:49.360'
DateTime actualTime = Convert.ToDateTime(strDate);
unfortunately the result is 2012-11-08 8:42:49 AM... the millisecond part is missing... Thanks in advance everyone.
|
|
|
|
|
The milliseconds portion is present - it's just not displayed by default. If you want to see it, you can use the "f" formatter like this:
Console.WriteLine(actualTime.ToString("yyyy-MM-dd hh:mm:ss.fff", CultureInfo.InvariantCulture));
|
|
|
|
|
Millisecond part is always there u can get it from there with
DateTime.TimeOfDay will give u full time with millisecond or
DateTime.Millisecond will return Millisecond.
|
|
|
|
|
Pete, BMS121,
Thank you so much for taking your time to respond to my post... I really appreciate it... but the solution both of you mentioned does not work for my situation... may be I did not state my question clearly... I apologize for that...
Pete, in your solution, you are converting the date to string again... that's not what i want...
And BMS121, I used the 'TimeOfDay' property as you suggested , but I could not assign that to datetime variable... I get compiler error :'Cannot implicitly convert System.TimeSpan to System.Datetime...
This is what I want to accomplish:
I am getting the datetime as a string from client ... so I have to convert that string to datetime including millisecond and then I have to store/save that datetime in the database (the datebase column is datetime type)...
Here is the code snippet:
string strDate = "2012-11-09 07:20:07.410"
Datetime actualDate = Convert.ToDateTime(strDate); -(L2)
L2 : does not return millisecond...
As per BMS121 suggestion, I tried the following :
(my entity object is called EDEntitiy)
Edentity.Timestamp = actualDate.TimeOfDay;
But above statement causes compiler error:
'Cannot implicitly convert System.TimeSpan to System.Datetime...
|
|
|
|
|
You are misunderstanding Pete's solution. Convert.ToDateTime is already giving you the right answer, but the default ToString on a DateTime omits the milliseconds, so it looks like it isn't when you look at the string representation of the DateTime you create. If you format it with milliseconds, you'll see that you got what you expected.
I just tried that very thing:
dt←$Convert:ToDateTime "2012-11-09 07:20:07.410"
09/11/2012 07:20:07
dt:Millisecond
410
dt:ToString "yyyy-MM-dd hh:mm:ss.fff"
2012-11-09 07:20:07.410
|
|
|
|
|
BobJanova,
Thanks. Really appreciate it. My issue is this.
string strDate = "2012-11-09 07:20:07.410"
Datetime actualDate = Convert.ToDateTime(strDate);
Now when I save this date (actualDate) in the database(I am using the Entity Frame work to connect to the database), this is what i see in the database : 2012-11-09 07:20:07.000
As you can see, the millisecond is zero in the database... so my question is how do I save date (after converting from string to datetime) with milliseconds... my datebase date column is SQL datetime type...
Thanks...
|
|
|
|
|
I think this is because SQL's DateTime is rubbish. If you need millisecond level precision you'd be better storing actualDate.Ticks in a 64 bit int.
|
|
|
|
|
<asp:DropDownList ID="DDLSorting" runat="server" AutoPostBack="True" onselectedindexchanged="DDLSorting_SelectedIndexChanged"
>
<asp:ListItem>Best Match</asp:ListItem>
<asp:ListItem>New Arrivals</asp:ListItem>
<asp:ListItem Value="3" Text="Price: Low to High"></asp:ListItem>
<asp:ListItem>Price: High to Low</asp:ListItem>
<asp:ListItem>Highest Discount</asp:ListItem>
</asp:DropDownList>
i have this dropdown
how can i sort values in the datalist control using this dropdown
|
|
|
|
|
|
What about them ?
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hmmm bacon
oops sorry invasion of a random though!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Seems to be happening a lot in here today
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
In a C# 2010 application, I used linq to sql to setup my database connections.
Now when I move the application to a different database, the original database is still being used. Basically the connection string is hard coded into theapplication.
I tried to follow the linq listed below, but everything did not work.
http://goneale.com/2009/03/26/untie-linq-to-sql-connection-string-from-application-settings/
The part that says, "1.Open up the LINQ to SQL designer, and open the Properties tab of the designer (the schema itself),
expand Connection and set Application Settings to False. ", I did not see this option.
The closest thing I found was connection and I set that value.
Here is the way the code looks now in the *designer.cs file.
namespace e_ClScripts
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="DEV")]
public partial class eDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void Inserte_Detail(e_Detail instance);
partial void Updatee_Detail(e_Detail instance);
partial void Deletee_Detail(e_Detail instance);
partial void InsertIBook(IBook instance);
partial void UpdateIBook(IBook instance);
partial void DeleteIBook(IBook instance);
partial void InsertIPackage(IPackage instance);
partial void UpdateIPackage(IPackage instance);
partial void DeleteIPackage(IPackage instance);
partial void InsertIError_Tran(instance);
partial void UpdateIError_Tran(IError_Tran instance);
partial void DeleteIError_Tran(IError_Tran instance);
partial void InsertTransaction_Type(Transaction_Type instance);
partial void UpdateTransaction_Type(Transaction_Type instance);
partial void DeleteTransaction_Type(Transaction_Type instance);
partial void Inserte_Tracking(e_Tracking instance);
partial void Updatee_Tracking(e_Tracking instance);
partial void Deletee_Tracking(e_Tracking instance);
#endregion
public eDataContext() :
base(global::e_ClScripts.Properties.Settings.Default.DEVConnectionString, mappingSource)
{
OnCreated();
}
public eDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public eDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
Here is what the app.config file looks like right now:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="e_ClScripts.Properties.Settings.DEVConnectionString"
connectionString="Data Source=instance1\DEV;Initial Catalog=dev3;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Can you tell me or show me in code how to fix my problem so the application does not
use the hard-coded values that were setup by linq to sql?
|
|
|
|
|
I don't use Linq to SQL but we have different config files for each environment. The UAT config file will have a different connection string pointing to the UAT server, when you compile for deployment you chose the config you want to use and make sure the config file has the correct connection string.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You are correct that each database has a different connection. However in code, can you show me how to change the connection string and how to change the app.config file to point to the different databases?
The way that linq to sql works is it hard codes the connection string. I want avoid this hardcoded connection string.
|
|
|
|
|
It is not a coding problem take a look at ConfigurationManager[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|