PDA

View Full Version : Outlook


Tr0jan
12-31-2004, 04:46 AM
Big new years smile to the C# Experts...

Ive wrote a small program in VB6 which strips attachments from a journal entry and save the attachment, this is then replaced by a hyperlink to the saved attachment.

I need to convert this into c# code, ive tried converters and that doesnt work well.

Ive come as far as reading the amount of attachments in journals, but cant seem to find any way of saving them, I can add, and remove.

If anybody can help me, this is the basic code I have for seeing the attachments:

static void Main(string[] args)
{

// Create an Outlook Application object.
Application outLookApp = new Application();
// Print all tasks.
NameSpace outlookNS = outLookApp.GetNamespace("MAPI");
MAPIFolder theTasks =
outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderJournal);
foreach(JournalItem task in theTasks.Items)
{
Console.WriteLine("-> Time Created: {0}", task.CreationTime);
Console.WriteLine("-> Subject: {0}", task.Subject);
Console.WriteLine("-> Body: {0}", task.Body);
Console.WriteLine("-> Attachments: {0}",task.Attachments.Count);

if (task.Attachments.Count > 0 )
{
Console.WriteLine ("This message has attachments");

}
}
}


Any help on saving these buggers will be appreciated.

nevarmore
12-31-2004, 04:32 PM
I'm not that keen on VB.

What does this:

NameSpace outlookNS = outLookApp.GetNamespace("MAPI");
MAPIFolder theTasks = outlookNS. GetDefaultFolder(OlDefaultFolders.olFolderJournal);


..do??

I'm sure I know the overall programming concept, but I'm not sure exactly what VB does. I assume that this somehow puts it into the MAPI namespace??

The best hit I found was this: http://www.csharphelp.com/board2/read.html?f=1&i=35525&t=35525

I'd suggest going through the MSDN docs for interfacing with outlook. Its an MS heavy language and an MS product, should be well documented.

Tr0jan
01-12-2005, 04:50 AM
Yes thank you for the reply, the VB code is all around, ive got a working version in VB, but C# version of this is required.

So the search goes on cap'n.

TR