Im trying to follow this Microsoft tutorial to display the names of a distribution list in c#
https://learn.microsoft.com/en-us/office/client-developer/outlook/pia/how-to-get-members-of-an-exchange-distribution-list
This example prompts the user to select an Exchange distribution list from the Select Names dialog box and expands the distribution list to display its members.
except when I get an error here
I have this in a console app project. How can I fix this?
You can fix this by creating an Application instance, as per suggestion made by the prompt in your screenshot. Like so:
Application app = new Application();
Outlook.SelectNamesDialog snd = app.Session.GetSelectNamesDialog();
Sources:
How to invoke a method with (Outlook.Application application) as parameter in C#?
Related
Good morning all,
I am currently working on project for myself to make my life a bit easier and get job done a bit faster, but unfortunately I have faced an issue. My understanding of c# is not as advanced yet and I hope someone will be able to give me some sort of clue or solution.
To the point. Is there a way to copy data displayed in one program and paste it into another?
let's say:
program_1 - command line app where all my code is being implemented to
program 2 - windows form app ( this is an existing .exe file added as reference to program_1)
When starting program_1 this trigger specific option in program_2 and program_2 display result on screen. What I want to do is to automatically copy content displayed in program_2 and:
a) save outcome as .txt using program_1
or
b) sent outcome directly to e-mail address, also using program_1
I was trying to use TextBox. options, GetData(), but I must be missing something. I would be much grateful for any sort of help.
Code:
Process app = Process.Start("SalesReport.exe");
Thread.Sleep(10000);
TextBox textBox1 = new TextBox();
textBox1.SelectAll();
textBox1.Copy();
app.Kill();
this is just basic function to launch report, this displays the result as table in program_2.
I am at a loss and could use some direction. I have a windows service that performs an Audit on customers. For new customers, I need to create a profile for each one. I already have a ASP.net C# web page that displays a single customer profile for the user:
http://webserver/showprofile.aspx?id=CustomerID
I would like to run some type of loop in the service that would render each new customer's profile and output all of those profiles into a PDF, Word Document, etc. Is there an easy way to do this using the existing Show Profile webpage?
If not, what is the best way to do this in C#? If it requires a component, I would prefer something free to very inexpensive. I currently have licenses for Telerik's complete line of tools if there is something there that can help. The bottom line, this has to be done programmatically as the user will have nothing to do with the generation/export to PDF. They will only access the resulting exported file.
Thanks in advance for your help.
You can use PdfCreator using the following command:
private PDFCreator.clsPDFCreator printer;
printer = new PDFCreator.clsPDFCreator();
printer.cDefaultPrinter = "PDFCreator";
printer.cOptions.UseAutosave = 0;
// Format in which file is to be saved. 0 if for pdf.
printer.cOptions.AutosaveFormat = 0;
printer.cClearCache();
printer.cStart();
foreach(int CustomerId in CustomerIDs)//array of customer ids as an example
{
printer.cPrintURL("http://webserver/showprofile.aspx?id=" + CustomerID.ToString());
}
You can download the software and necessary dll at the following link and look at the examples in the .net folder.
http://sourceforge.net/projects/pdfcreator/
I'm creating a setup program for an application that will require the user to choose between three setup options. I would like to take the result of the user input and write to the registry, so that the application can read this value at run-time. From what I've read so far I've been able to create the custom dialog with radio buttons, but what I haven't been able to find is how to take the result of the user's selection and then run a custom action which will write the result to the registry. I assume I can write a small script or executable which I can launch from the custom action by adding this script or exe by adding it to the application folder, but how do I get the value selected to be passed to this script or exe?
Thanks for any advice.
Maybe those links will help you:
RadioButtons User Interface Dialog Box
How to: Set Conditional Installation Based on User Choices
creating setup c#
My two cents: I think you may consider using another suite to create your installation, like Installshield. The VS 2010 setup program is, IMHO, not a good setup program.
I am working on a WPF app (written in C#) that searches and serves data from the active directory. Searching for a user will fetch all phone numbers for the user and display on the app window.
How can I open the outlook contact card by the click of some icon or the username or something?
The Outlook Contact Card is part of Microsoft Outlook and (as far as I know) not a public control, so you can not simply 'open' it unless you are creating an Outlook add-in.
Using the Active Directory's information you could recreate it.
By Outlook Contact Card I assume you mean a vCard (*.VCF file). It is actually nothing more than a text file. You can easily recreate it. For example:
Create a StringBuilder instance and write the contents of the .VCF file to it.
var vcf = new StringBuilder();
vcf.Append("TITLE:" + contact.Title + System.Environment.NewLine);
//...
Afterwards you can save it to a file.
var filename = #"C:\mycontact.vcf";
File.WriteAllText(filename, vcf.ToString());
Most properties are easy to figure out.
A small example:
BEGIN:VCARD
FN:Mr. John Smith
TITLE:Developer
ORG:Microsoft
BDAY:1979-12-10
VERSION:2.1
END:VCARD
If you want to include an image you have to base 64 encode it.
If you open this newly created file:
Process.Start(#"C:\mycontact.vcf");
Then it should be opened by the application that is configured by default to handle this file extension.
Wikipedia contains more information about the contents of a vCard:
http://en.wikipedia.org/wiki/VCard
It seems that outlook is using a Lync Feature.
Even if not exactly the Same you can use the Lync SDK in your wpf app if you use Lync.
http://msdn.microsoft.com/en-us/uc14trainingcourse_2l_topic2#_Toc273951814
I am using the Windows API Code Pack for Microsoft .NET Framework to try out of some of the new UI features of the Win7 taskbar. I am coding in C#.
I have a question regarding jumplists. All of the sample code provided assumes that the entries on the jump list are used to call out to run a particular application or open a document, e.g. a text document in a MRU list or run mspaint.exe.
I would like to implement some items which allow me to set state in my own application (i.e. the app which is interacting with the taskbar). MSN Messenger does this, for example, when you can set your status (Busy, Offline etc.).
Try as I might, I cannot create a JUmpListItem or JumpListLink to behave in this way - it treats them as applications or documents.
Does anyone have any samples of how to create an item which raises an event in the same application that created it? I am sure it is simple but I am being very daft.
Many thanks for your help.
I believe what you'd want to do is to call your application with a special set of flags (i.e. launch the executable with certain arguments). At application start up, you'd check to see what flags are set, then send a message to the main instance of the application and then exit out of the new instance.
Using the TaskBarDemo, to open an item created by your application would have to be referenced, ie if your program created a PDF file you would do this:
jumpList.AddUserTasks(new JumpListLink(Path.Combine(systemFolder, "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRD32.exe"), "Open Adobe Reader")
{
IconReference = new IconReference(Path.Combine(systemFolder, "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRD32.exe"), 0)
});
Otherwise you would have to ensure that your application registered file associations, for recent or frequent items.
I had a few problems with jumplists with the API Pack, i now use VS 2010 Beta 2 and let shell handle the jumplists.
Hope this is helpfull.
These tasks are some sort of IShellLink. Then, you should call ICustomDestinationList's AddUserTasks. Look up samples in Windows 7 Training Kit.