Home > Archive > C# > November 2004 > Please translate VB code that uses MAPI to C#
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Please translate VB code that uses MAPI to C#
|
|
|
| Hello C# gurus out there,
I'm starting to learn C# from scratch and really need help. I just
need 2 lines in this code translated to C#. Here is a piece of code
that works in VB.NET:
This code looks up an email message and finds the sender's address:
Dim objSession As MAPI.Session
Dim objCDOMsg As MAPI.Message
Const g_PR_SMTP_ADDRESS_W = &H39FE001F ' C# Syntax for this?
objSession = CreateObject("MAPI.Session")
objSession.Logon("", "", False, False)
' pass message to CDO
objCDOMsg = objSession.GetMessage(SomeID)
' get sender address
Dim strAddress As String
strAddress = objCDOMsg.Sender.Fields(g_PR_SMTP_ADDRESS_W).value 'C#
syntax?
MsgBox (strAddress)
Thanks in advance for your help!
Tanya
| |
|
| I got it to work!
vndaxanh@yahoo.com (Tanya) wrote in message news:<3c5e8dab.0411091432.7dfa8056@posting.google.com>...
> Hello C# gurus out there,
>
> I'm starting to learn C# from scratch and really need help. I just
> need 2 lines in this code translated to C#. Here is a piece of code
> that works in VB.NET:
>
> This code looks up an email message and finds the sender's address:
>
> Dim objSession As MAPI.Session
> Dim objCDOMsg As MAPI.Message
> Const g_PR_SMTP_ADDRESS_W = &H39FE001F ' C# Syntax for this?
>
> objSession = CreateObject("MAPI.Session")
> objSession.Logon("", "", False, False)
>
> ' pass message to CDO
> objCDOMsg = objSession.GetMessage(SomeID)
> ' get sender address
> Dim strAddress As String
> strAddress = objCDOMsg.Sender.Fields(g_PR_SMTP_ADDRESS_W).value 'C#
> syntax?
> MsgBox (strAddress)
>
> Thanks in advance for your help!
>
> Tanya
| |
|
| Hi there,
Here is ur code in c#.
//////////////////////////////////
public MAPI.Session objSession;
public MAPI.Message objCDOMsg;
const float g_PR_SMTP_ADDRESS_W = 0X39FE001;
// C# Syntax for this?
objSession = Microsoft.VisualBasic.Interaction.CreateObject("MAPI.Session");
objSession.Logon("", "", false, false);
// pass message to CDO
objCDOMsg = objSession.GetMessage(SomeID);
// get sender address
string strAddress = "";
strAddress = objCDOMsg.Sender.Fields(g_PR_SMTP_ADDRESS_W).value;
//C# syntax?
MessageBox.Show(strAddress);
///////////////////////////////////
vndaxanh@yahoo.com (Tanya) wrote in message news:<3c5e8dab.0411100928.5411c8cf@posting.google.com>...[color=darkred]
> I got it to work!
>
> vndaxanh@yahoo.com (Tanya) wrote in message news:<3c5e8dab.0411091432.7dfa8056@posting.google.com>...
|
|
|
|
|