I'm going crazy on this one.
Basically I want to retrieve a task based on the EntryID of this task.
so what I do is the following:
Outlook.MAPIFolder outlookTasksFolder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
string filter = String.Format("#SQL=\"urn:schemas:tasks:entryid\" like '%{0}%'", myEntryID);
Outlook.Items outlookTasksDataItems = outlookTasksFolder.Restrict(filter);
but i does not work.
I don't know how to format my query to get the corresponding items (there should be only one really).
can anyone please help me?
thank you
Outlook.MAPIFolder outlookTasksFolder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
Outlook.TaskItem myOutlookTask = (Outlook.TaskItem)Application.Session.GetItemFromID(myEntryID, outlookTasksFolder.EntryId);
That should do it.
Related
I use the following method to a new OutlookUserProperty to an AppointmentItem:
MyID = (Outlook.UserProperty)myAppointment.ItemProperties.Add("MyID", Outlook.OlUserPropertyType.olText, false, 1);
... later I want to remove exactly this "MyID" from the ItemProperties collection.
Obviously I can only remove an item from the ItemProperties collection using the
myAppointment.ItemProperties.Remove(index).`
Unfortunately I don't know the index of the element "MyID", and I cannot find any method for retrieving the index of "MyID".
I think you can use UserProperty.Delete to delete your ItemProperty.
UserProperty up = myMailItem.UserProperties["ParentMailRecipients"];
if(up != null)
up.Delete();
More info about: UserProperty
Reference: outlook 2007 addin : How to remove particular userproperty of mailItem
Hope it works for you.
Use PropertyAccessor.DeleteProperty.
To figure out the DASL property name, take a look at the item with OutlookSpy (I am its author - click IMessage button, select the property, look at the DASL property editor).
net. I have a doubt. How do we introduce user defined variables as parameters in where clause of a LINQ query. I am querying an XML file. Here is my code
XElement books = XElement.Load(#"Friends.xml");
var titles =
from book in books.Elements("Friend")
where (string)book.Element("Date") == "27" && (string)book.Element("Month") == "05"
select book.Element("Name");
foreach (var title in titles)
Console.WriteLine(title.Value);
Instead of harcoding values 27 and 05, I want to use variables instead.How to use them?
Sorry for the dumb question, I misunderstood the problem. Actually I am blocking certain dates in a calendar. Now using the
private void calendar1_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{....}
works only for non blocked dates. Since a particular day I tried with the variable was a blocked one, it wasn't working. Now please suggest me a solution for this. All I need is to click on a date(blocked or non blocked) and I have to run a event. Which event should I use??
use a simply variable:
XElement books = XElement.Load(#"Friends.xml");
string yourDate = "27";
string yourMonth = "05";
var titles =
from book in books.Elements("Friend")
where (string)book.Element("Date") == yourDate && (string)book.Element("Month") == yourMonth
select book.Element("Name");
foreach (var title in titles)
Console.WriteLine(title.Value);
And so on. Of course, use good names that are readable according your code and system
In addition, I think you could define a class of book with appropriate properties as XML tag. For example :
class Book {
string Date {...} //
}
It's could be quite easy when reading XML file. Moreover, it could be nice if you build your own tree data structures executing XML file.
I need to search for accounts in Microsoft CRM, using a wildcard search to get a "contains" search for the user's input. So if the user enters "ABC", I use ConditionOperator.Like and the value "%ABC%".
My question is, how would I search for a customer name that contains a percentage sign, such as "100% Great llc"? I can't find a way to escape the %.
Sounds like you're looking for a SQL-based approach so I'm not sure if this helps.
One way I know is through the user interface with an asterisk *
So if you want to find all of the accounts that have a % sign just type in *% into the account search.
Try using square blocks for special characters, for instance like [%]. So the condition would be: 100[%] Great llc or %100[%] Great llc%.
--EDIT--
This is in response to your comment.
Try utilizing the ConditionExpression, something like following:
//1. Condition expression.
ConditionExpression nameCondition= new ConditionExpression();
nameCondition.AttributeName = "AccountName";
nameCondition.Operator = ConditionOperator.Like;
nameCondition.Values = new string[] { "%100[%] Great llc%" };
//2. Create filter expression
FilterExpression nameFilter = new FilterExpression();
nameFilter.Conditions = new ConditionExpression[] { nameCondition };
//3. Provide columns
ColumnSet resultSetColumns = new ColumnSet();
resultSetColumns.Attributes = new string[] { "name", "address" };
//4. Prepare query expression
QueryExpression qryExpression = new QueryExpression();
qryExpression.Criteria = nameFilter;
qryExpression.ColumnSet = resultSetColumns;
//5. Set the table to query.
qryExpression.EntityName = EntityName.account.ToString();
//6. BusinessEntityCollection accountsResultSet = service.RetrieveMultiple(qryExpression);
Though I have played alot with CRM, but never came across special characters scenario. Let me know your findings. This article has some revelations.
I'm learning to use Crystal Reports (with VB 2005).
Most of what I've seen so far involves slurping data directly from a database, which is fine if that's all you want to display in the report.
My DB has a lot of foreign keys, so the way I've tried to stay sane with presenting actual information in my app is to add extra members to my objects that contain strings (descriptions) of what the foreign keys represent. Like:
Class AssetIdentifier
Private ID_AssetIdentifier As Integer
Private AssetID As Integer
Private IdentifierTypeID As Integer
Private IdentifierType As String
Private IdentifierText As String
...
Here, IdentifierTypeID is a foreign key, and I look up the value in a different table and place it in IdentifierType. That way I have the text description right in the object and I can carry it around with the other stuff.
So, on to my Crystal Reports question.
Crystal Reports seems to make it straightforward to hook up to records in a particular table (especially with the Experts), but that's all you get.
Ideally, I'd like to make a list of my classes, like
Dim assetIdentifiers as New List(Of AssetIdentifier)
and pass that to a Crystal Report instead of doing a tight link to a particular DB, have most of the work done for me but leaving me to work around the part that it doesn't do. The closest I can see so far is an ADO.NET dataset, but even that seems far removed. I'm already handling queries myself fine: I have all kinds of functions that return List(Of Whatever) based on queries.
Is there an easy way to do this?
Thanks in advance!
UPDATE: OK, I found something here:
http://msdn.microsoft.com/en-us/library/ms227595(VS.80).aspx
but it only appears to give this capability for web projects or web applications. Am I out of luck if I want to integrate into a standalone application?
Go ahead and create the stock object as described in the link you posted and create the report (StockObjectsReport) as they specify. In this simplified example I simply add a report viewer (crystalReportViewer1) to a form (Form1) and then use the following code in the Form_Load event.
stock s1 = new stock("AWRK", 1200, 28.47);
stock s2 = new stock("CTSO", 800, 128.69);
stock s3 = new stock("LTWR", 1800, 12.95);
ArrayList stockValues = new ArrayList();
stockValues.Add(s1);
stockValues.Add(s2);
stockValues.Add(s3);
ReportDocument StockObjectsReport = new StockObjectsReport();
StockObjectsReport.SetDataSource(stockValues);
crystalReportViewer1.ReportSource = StockObjectsReport;
This should populate your report with the 3 values from the stock object in a Windows Form.
EDIT: Sorry, I just realized that your question was in VB, but my example is in C#. You should get the general idea. :)
I'm loading the report by filename and it is working perfect:
//........
ReportDocument StockObjectsReport;
string reportPath = Server.MapPath("StockObjectsReport.rpt");
StockObjectsReport.Load(reportPath);
StockObjectsReport.SetDataSource(stockValues);
//Export PDF To Disk
string filePath = Server.MapPath("StockObjectsReport.pdf");
StockObjectsReport.ExportToDisk(ExportFormatType.PortableDocFormat, filePath);
#Dusty had it. However in my case it turned out you had to wrap the object in a list even though it was a single item before I could get it to print. See full code example:
string filePath = null;
string fileName = null;
ReportDocument newDoc = new ReportDocument();
// Set Path to Report File
fileName = "JShippingParcelReport.rpt";
filePath = func.GetReportsDirectory();
// IF FILE EXISTS... THEN
string fileExists = filePath +#"\"+ fileName;
if (System.IO.File.Exists(fileExists))
{
// Must Convert Object to List for some crazy reason?
// See: https://stackoverflow.com/a/35055093/1819403
var labelList = new List<ParcelLabelView> { label };
newDoc.Load(fileExists);
newDoc.SetDataSource(labelList);
try
{
// Set User Selected Printer Name
newDoc.PrintOptions.PrinterName = report.Printer;
newDoc.PrintToPrinter(1, false, 0, 0); //copies, collated, startpage, endpage
// Save Printing
report.Printed = true;
db.Entry(report).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
}
catch (Exception e2)
{
string err = e2.Message;
}
}
I need to, preferably in C# - but c++ will do, find a way to filter the list of printers in the windows print dialog for any windows printing.
I have come across WinAPIOverride and have figured I am going to have to write my own dll which overrides the method to get the printers list, then filter it and return it. I would then have to inject the dll into all running processes.
Can anybody assist me with something that is already developed or perhaps an easier way of accomplishing this? The only way the list of printers comes out is from the API method call and I have even considered modifying the registry, but this will slow down the response of the print dialog box to the point that it would be annoying to the user.
I don't think that (re)writing a DLL is the easiest method. Why not use WMI to retrieve the wanted information (printers in this case)?
The following code is for retrieving all the locally installed printers:
(code samples borrowed from here)
ManagementScope objScope = new ManagementScope(ManagementPath.DefaultPath); //For the local Access
objScope.Connect();
SelectQuery selectQuery = new SelectQuery();
selectQuery.QueryString = "Select * from win32_Printer";
ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery);
ManagementObjectCollection MOC = MOS.Get();
foreach (ManagementObject mo in MOC) {
listBox1.Items.Add(mo["Name"].ToString().ToUpper());
}
To get the printers known accross a domain use this:
ConnectionOptions objConnection = new ConnectionOptions();
objConnection.Username = "USERNAME";
objConnection.Password = "PASSWORD";
objConnection.Authority = "ntlmdomain:DDI"; //Where DDI is the name of my domain
// Make sure the user you specified have enough permission to access the resource.
ManagementScope objScope = new ManagementScope(#"\\10.0.0.4\root\cimv2",objConnection); //For the local Access
objScope.Connect();
SelectQuery selectQuery = new SelectQuery();
selectQuery.QueryString = "Select * from win32_Printer";
ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery);
ManagementObjectCollection MOC = MOS.Get();
foreach (ManagementObject mo in MOC) {
listBox1.Items.Add(mo["Name"].ToString().ToUpper());
}
Of course, the list is not "filtered" as you would like as you didn't specify any criteria. But I'm sure you can manage from here on by yourself.
Thanks for the interesting code.
The idea is to apply a filtered printer list to the system as globally as possible without interfering with the user. This means the filtered list has to apply to the standard windows print dialogs unfortunately...
So your WMI code, albeit kind of cool, would not be appropriate. If I were building my own print dialogs, it could come in pretty handy ;)