So, I want to export all my contacts from Outlook as vcards. If I google that, I get a bunch of shareware programs, but I want something free that just works.
If I'm to code it myself, I guess I should use the Microsoft.Office.Interop.Outlook assembly. Has anyone already code to convert ContactItems to vcards?
Edit: I solved it in a completely different way, see answer below, but I have marked dok1.myopenid.com's answer as accepted because it answers my original question.
I solved it in a non-programmatically way:
Selected all contacts in Outlook
Forwarded them as cards to myself
Saved all the attachments (vcards) in a folder, c:\temp
Opened a command prompt and typed the command copy /a *.vcf c:\allcards.vcf which concatenates all vcards into one
For what it's worth - I just came across this thread looking for the same export to individual .VCF files from outlook. I haev 2007 (don't know if that makes a difference) but I selected all contacts and dragged them to a new email message to be added as individual .VCF files. After they were all added, I clicked in the attachments section of the new email, hit CTRL-A to highlight all of them, then left-click-dragged the first (and therefore all of them) to the folder I wanted the individual .VCF files in. A few minutes of Outlook "thinking" about my 400 contacts they were all there!
They sure make it hard to find, don't they? See if this helps.
http://msdn.microsoft.com/en-us/library/aa579624(EXCHG.80).aspx
That includes: The following example uses the CDO Person object to obtain vCard information for a contact.
Dim oPerson As New CDO.Person
Dim strm As New ADODB.Stream
' Assume strURL is a valid URL to a person contact item
oPerson.DataSource.Open strURL
' You can set the ADO Stream object to the returned vCard stream
Set strm = oPerson.GetvCardStream
' Save the stream to a file.
' Note: using adSaveCreateOverwrite may cause an existing
' contact to be overwritten.
strm.SaveToFile "d:\vcard.txt", adSaveCreateOverwrite
' You don't have to set a Stream object,
' just use the Stream methods off GetvCardStream directly
oPerson.GetvCardStream.SaveToFile "d:\vcard.txt", adSaveCreateOverwrite
Yep, the only code sample there is in VB.
Just purchased the X8 and was about to get really really mad when I couldn't easily transfer my contacts...until I started snooping around on the phone.
First, export all your contacts in Outlook to vCards (I found emailing them to yourself is the easiest. If you get an error message "to many attachments..." you can save them from the email in your sent items folder) and copy the vCards to the memory card on your phone.
Second, open your address book on the phone then press the left button on the phone (the button with 4 little squares above it. NOT THE 4 BOXES ON THE SCREEN...THE PHYSICAL BUTTON!).
Third, select "Import/Export" and choose import from memory card. Import all vCard files and you should be golden.
Best of luck...don't ask me any questions because I will not be back to look at any more posts...just passing by trying to figure it out on my own.
Related
For the last 7 years I've been using the Journal entries feature of Outlook to generate daily engineering log entries detailing what I've been working on day-to-day. It looks like MS are 'retiring' the Journal feature in the near future and I'd like to retain my 1000+ log entries.
Ideally I would like to export all the Journal entries into a SQLite database and use it as the basis of a new engineering log tool.
Reviewing the available MSDN documentation I was only able to find scant details on programmatically accessing Outlook data. I did identify a number of pay for/open source NuGet packages for accessing Outlook data, but none of them seemed to cover Journal entries.
Has anyone recommend a NuGet package/GitHub project which would handle this, or even a code snippet highlighting accessing Outlook Journal entries ?
JournalItem object can be accessed using Outlook Object Model just fine. Open the default Journal folder using Application.Session.GetDefaultFolder(olFolderJournal), loop through all items in that folder (cast them to JournalItem).
You can use the GetDefaultFolder method to get the Journal folder which contains corresponding items. Just pass the olFolderJournal value. For example, the following VBA macro which can be run on Outlook shows how to get the Journal folder:
Public Sub OpenJournalEntry()
Dim JournalFolder As Folder
Dim Item As Object
Set JournalFolder = Session.GetDefaultFolder(olFolderJournal)
Set Items = JournalFolder.Items
Set Item = Items.Item(1)
Item.Display
End Sub
I should create a C# application to manage the mail and attachments that arrive to me on Office 365 (Outlook).
In the app I would like to select from which domains you need to download the mail, based on this the app downloads only the related emails with attachments and shows them to me. This way I can decide what to print or not.
I need this app because I have to record all the projects that come to me from clients, architecture projects and therefore I need to divide everything according to the client.
Can you tell me what is the best way to develop this?
I mean if it is better to create VSTO for Outlook or something else or if there is other way. I would like to start with the right method.
I had thought about installing Outlook on the client, synchronized with Office 365, creating a VSTO that takes care of copying the interested emails (selecting just the domains of interest) and putting attachments in various folders, showing the attachments in an orderly manner and grouped.
Can you suggest me the best method?
I mean at the structural level (how to design system), and not at the code level (which I think I know it).
Thanks so much
You are right, you can develop a VSTO based add-in where you may handle the NewMailEx event of the Application class. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.
The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. Use this method with caution to minimize the impact on Outlook performance.
To save the attached files you can use the MailItem.Attachments property which returns an Attachments object that represents all the attachments for the specified item. Use the Attachment.SaveAsFile method which saves the attachment to the specified path.
If TypeName(myItem) = "MailItem" Then
Set myAttachments = myItem.Attachments
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the first attachment in the current item to the Documents folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
myAttachments.Item(1).SaveAsFile Environ("HOMEPATH") & "\My Documents\" & _
myAttachments.Item(1).DisplayName
End If
Else
MsgBox "The item is of the wrong type."
End If
End Sub
See Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly.
I want to take backups of all emails from SQL Server database and need to create it's backup file using C# code in outlook compatible format. So that emails can be restored in outlook software.
Please help
Till now we have created one desktop application and we have table containing emails which has some custom fields also as per our need.
We have done some exploration on it and found given below links -
Can I read an Outlook (2003/2007) PST file in C#?
http://www.c-sharpcorner.com/article/outlook-integration-in-C-Sharp/
https://www.add-in-express.com/creating-addins-blog/2013/12/20/create-outlook-files/
Can I read an Outlook (2003/2007) PST file in C#?
My problem is that we have some custom fields in database so how they will get stored in outlook data files
Email table structure is given below -
You can use Outlook Object Model and its Namespace.AddStore/AddStoreEx methods to add new or existing PST file to a profile and then (given the returned Store object) populate it with folders and emails. To store custom properties, use MailItem.UserProperties collection.
Note however that OOM will not work in a service - you'd need Extended MAPI (C++ or Delphi) or Redemption (I am its author - any language) for that. Creating items in the sent state can also be a challenge. If using Redemption is an option, it exposes RDOSession.LogonPstStore method that create (and deletes) a temporary profile configured to work with the specified PST file. It can be used i na service. No existing Outlook profiles are affected.
Redemption.RDOSession session = new Redemption.RDOSession();
Redemption.RDOPstStore store = session.LogonPstStore(PstFileName);
Redemption.RDOFolder folder = store.IPMRootFolder.Folders.Add("Backup folder");
RDOMail item = folder.Items.Add("IPM.Note");
item.Sent = true;
item.Subject = "test";
item.Body = "test body";
item.Recipients.AddEx("The User", "user#domain.demo", "SMTP");
item.UserProperties.Add("My custom prop", olText).Value = "custom prop value";
item.Save();
Your description is still not precise enough.
Do you want to store individual e-mails from outlook into database and eventually get them back as e-mails in Outlook?
Then it looks like you have all you need.
MailItem in Outlook has more-less properties like you in database.
Then conceptually it should look like this:
Enumarate MAPIFolder and for each e-mail store properties inside database and then delete e-mail.
In case of restoring read database record, create new MailItem and add it to folder.
BUT:
I see some problems with field types - i.e. EmailTo nvarchar(100) is far too small.
Additionally you don't have all fields to restore e-mail 1:1.
So i.e. storing msg file could be good option (maybe additionally to data you are retrieving).
Please specify more details then I could also answer in better way.
EDIT:
According to your clarification (still not sure if I understand correctly):
Simpliest way would be to use outlook for this process.
Create in outlook pst folder, create e-mails inside and then backup complete pst file (then you have all in one file) or export individually e-mails to .msg files (then 1 file per e-mail).
Trying to write directly from your application to pst file or to msg file could be very hard since format of those files are not described.
Please precise if you want to use Outlook for this process or not.
I am working on a WPF 4.5 application which needs to interact with PDFs and I am stuck with an issue as described below:
I have template pdfs stored at a specific location. Based on requirement, a copy of the template pdf is created. This pdf has certain fields including text boxes, dropdowns etc. Some of these fields need to be pre-populated like the dropdown values.
Once it is ready, I need to open it, and let the user complete the form. Once completed, the user saves the file and closes it.
Now I need to read the file and send the updated data to the DB. I was able to do all this using iTextSharp by launching the PDF in a separate process and handling the Exited event. Now, the problem I face is this solution does not work if the user uses the SaveAs option to change the name or location of the opened file.
I thought if it would be possible to disable the Save options and add a button on the form clicking which would automatically save the form and close it at the expected location would be a possible solution.
My questions are:
1) Is it possible to find out using the argument of the Exited event handler to find out the saved file name and location? As soon as the user saves the file with a different name, the title of the reader gets updated with the current file name. So I am assuming that the current process is using the latest file.
2) Is it possible to disable the SaveAs and Save file options and close the file on click of a button in the form, using Adobe SDK (JavaScript or plugin or API)?
3) If I use the Adobe SDK, do all the systems on which the application would be installed need to have a licensed version of the Adobe Acrobat?
If the above options are not possible then we would have to settle with dynamic forms. We wanted to experiment with PDF since it is easy to create, and supports image annotations, for which we might need to develop a separate solution, if the above options are not feasible.
I know this is not a very specific programming question, but I need help in order to be able to figure out which path I can go on to be able to achieve the goal.
Please mark duplicate with the link to the other SO question if it a duplicate since I have not been able to figure out one.
Would appreciate answers, links to other posts on SO that are specific to the questions asked.
Please avoid opinion based answers.
Any help would be appreciated.
Any constructive criticism is also welcome.
There is a heavy-handed way to prevent an Acrobat user from Saving a file. In Acrobat, create a Javascript that executes when "Document Will Save." A script like this causes the application to hang rather than Save the file:
var key = "" + this.getField("Password").value;
if (key != "QWERTY") {
app.alert ("No changes to this PDF are allowed,
so you may not Save it.
You will now have to Force Quit or End Task.");
while (true) {};
}
I am not proud of this, but it does the job. You might want to erase the password field before saving.
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