Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Multiple connectionstring Pin
User34907-Jul-13 9:58
User34907-Jul-13 9:58 
GeneralRe: C# Multiple connectionstring Pin
Mycroft Holmes7-Jul-13 12:58
professionalMycroft Holmes7-Jul-13 12:58 
GeneralRe: C# Multiple connectionstring Pin
Dave Kreskowiak7-Jul-13 15:03
mveDave Kreskowiak7-Jul-13 15:03 
QuestionC# with VS2012 read outlook pst message and record Pin
蔡豐駿7-Jul-13 4:53
蔡豐駿7-Jul-13 4:53 
AnswerRe: C# with VS2012 read outlook pst message and record Pin
OriginalGriff7-Jul-13 5:12
mveOriginalGriff7-Jul-13 5:12 
GeneralRe: C# with VS2012 read outlook pst message and record Pin
蔡豐駿7-Jul-13 5:36
蔡豐駿7-Jul-13 5:36 
QuestionRe: C# with VS2012 read outlook pst message and record Pin
OriginalGriff7-Jul-13 5:41
mveOriginalGriff7-Jul-13 5:41 
AnswerRe: C# with VS2012 read outlook pst message and record Pin
蔡豐駿7-Jul-13 15:26
蔡豐駿7-Jul-13 15:26 
I have copy this from Microsoft "http://support.microsoft.com/kb/310258/zh-tw"
And I still cannot get my outlook message.

=================================================
using System;
using System.Reflection; // to use Missing.Value

//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.
//using Outlook = Microsoft.Office.Interop.Outlook;


namespace ConsoleApplication1
{
public class Class1
{
public static int Main(string[] args)
{
try
{
// Create the Outlook application.
// in-line initialization
Outlook.Application oApp = new Outlook.Application();

// Get the MAPI namespace.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

// Log on by using the default profile or existing session (no dialog box).
oNS.Logon(Missing.Value, Missing.Value, false, true);

// Alternate logon method that uses a specific profile name.
// TODO: If you use this logon method, specify the correct profile name
// and comment the previous Logon line.
//oNS.Logon("profilename",Missing.Value,false,true);

//Get the Inbox folder.
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

//Get the Items collection in the Inbox folder.
Outlook.Items oItems = oInbox.Items;

// Get the first message.
// Because the Items folder may contain different item types,
// use explicit typecasting with the assignment.
Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();

//Output some common properties.
Console.WriteLine(oMsg.Subject);
Console.WriteLine(oMsg.SenderName);
Console.WriteLine(oMsg.ReceivedTime);
Console.WriteLine(oMsg.Body);

//Check for attachments.
int AttachCnt = oMsg.Attachments.Count;
Console.WriteLine("Attachments: " + AttachCnt.ToString());

//TO DO: If you use the Microsoft Outlook 10.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments.Item(i).DisplayName);
}*/

//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments[i].DisplayName);
}*/


//Display the message.
oMsg.Display(true); //modal

//Log off.
oNS.Logoff();

//Explicitly release objects.
oMsg = null;
oItems = null;
oInbox = null;
oNS = null;
oApp = null;
}

//Error handler.
catch (Exception e)
{
Console.WriteLine("{0} Exception caught: ", e);
}

// Return value.
return 0;

}
}
}
Generalhow to link dll with exe Pin
Yashwanth. C.b7-Jul-13 1:24
Yashwanth. C.b7-Jul-13 1:24 
SuggestionRe: how to link dll with exe Pin
Richard MacCutchan7-Jul-13 1:32
mveRichard MacCutchan7-Jul-13 1:32 
GeneralRe: how to link dll with exe Pin
OriginalGriff7-Jul-13 1:41
mveOriginalGriff7-Jul-13 1:41 
GeneralRe: how to link dll with exe Pin
Richard MacCutchan7-Jul-13 1:51
mveRichard MacCutchan7-Jul-13 1:51 
GeneralRe: how to link dll with exe Pin
Yashwanth. C.b9-Jul-13 15:52
Yashwanth. C.b9-Jul-13 15:52 
GeneralRe: how to link dll with exe Pin
Richard MacCutchan9-Jul-13 21:25
mveRichard MacCutchan9-Jul-13 21:25 
GeneralRe: how to link dll with exe Pin
OriginalGriff7-Jul-13 1:48
mveOriginalGriff7-Jul-13 1:48 
GeneralRe: how to link dll with exe Pin
Richard MacCutchan7-Jul-13 1:52
mveRichard MacCutchan7-Jul-13 1:52 
GeneralRe: how to link dll with exe Pin
Richard MacCutchan7-Jul-13 1:56
mveRichard MacCutchan7-Jul-13 1:56 
GeneralRe: how to link dll with exe Pin
OriginalGriff7-Jul-13 2:02
mveOriginalGriff7-Jul-13 2:02 
JokeAnd another thing Pin
Richard MacCutchan7-Jul-13 1:58
mveRichard MacCutchan7-Jul-13 1:58 
GeneralRe: And another thing Pin
OriginalGriff7-Jul-13 2:06
mveOriginalGriff7-Jul-13 2:06 
QuestionIntegral Height for ComboBox Pin
Manoj Salem6-Jul-13 23:35
Manoj Salem6-Jul-13 23:35 
AnswerRe: Integral Height for ComboBox Pin
Richard MacCutchan7-Jul-13 1:28
mveRichard MacCutchan7-Jul-13 1:28 
QuestionC# event for Idenify Mouse click or key down Pin
Manoj Salem6-Jul-13 23:31
Manoj Salem6-Jul-13 23:31 
AnswerRe: C# event for Idenify Mouse click or key down Pin
Mycroft Holmes7-Jul-13 12:52
professionalMycroft Holmes7-Jul-13 12:52 
QuestionE-prescription system full source code Pin
Mootje0706-Jul-13 11:54
Mootje0706-Jul-13 11:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.