472,799 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 software developers and data experts.

C#, VB and Exchange

Guys,

I am working on a new web site for our company and have started to move my
code from VB.Net to C#. I have ran into a snag that I can't seem to figure
out. I am trying to create an Exchange mailbox for a user ID that I just
created using System.DirectoryServices. I have created the user, set the
password, and enabled the account.

When I try and create the mailbox I get a "The parameter is incorrect" error
message on mailbox.CreateMailbox(strServe); line. I have ran just about
100% of this code in VB.Net and it works great. I tracted back the
strServer in the configuration view of ADSI Edit. It appears to be correct
and if I take the exact text it creates and put it in a VB app it works.
It looks like it's the way I am implementing the following two lines.

mailbox = (IMailboxStore)oUser.NativeObject;
mailbox.CreateMailbox(strServer);

The stack trace on the error page is showng this

[ArgumentException: The parameter is incorrect.]
CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL) +0
Crossmark.Enterprise.CAPUserCreate.Common.Exchange .CreateMailBox(String
strUserPath, String MailBoxEnding, Char firstletter) in c:\documents and
settings\tim.sapp\my documents\visual studio
projects\crossmark.enterprise.capusercreate\crossm ark.enterprise.capusercreate.common\exchange.cs:89
Crossmark.Enterprise.CAPUserCreate.UI._default.Cre ateUser_Button_Click(Object
sender, EventArgs e) in
c:\inetpub\wwwroot\crossmark.enterprise.capusercre ate.ui\default.aspx.cs:122
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
Looks like it does not list the strServer when it tries to put the info into
the user account.

I am using the same security premissons in the VB and C# app so I know that
is not a problem.

When I put the create mail in a try the exception message is "The parameter
is incorrect" and the InnerException is blank.

Here is what I am running on...

DevBox
WinXP Pro
Visual Studio 2003
..Net Framework 1.1 (1.1.4322 SP1)
CDO Exchange Managment installed.
-

Exchange 2003
(Running on Windows 2003)

-

Active Directory
Windows 2003 (No Mixed Mode)

//************************************************** *******
//************************************************** *******

using System;
using System.DirectoryServices;
using CDOEXM;
namespace Crossmark.Enterprise.CAPUserCreate.Common
{
/// <summary>
/// Summary description for Exchange.
/// </summary>
public class Exchange
{
protected string ServerName;
protected string StorageGroup;
protected IMailboxStore mailbox;

public bool CreateMailBox( string strUserPath, string MailBoxEnding, char
firstletter)
{
DirectoryEntry oUser = new DirectoryEntry(strUserPath);
oUser.Username = Common.Constants.ActiveDirectorySettings.ADUserNam e;
oUser.Password = Common.Constants.ActiveDirectorySettings.ADPasswor d;
int temp = Convert.ToInt32(firstletter);

switch(temp)
{
case 65:
case 66:
ServerName = "CN=DALEXCBE01";
StorageGroup = "CN=AB" + MailBoxEnding + "CN=AB";
break;
case 67:
case 68:
ServerName = "CN=DALEXCBE01";
StorageGroup = "CN=CD" + MailBoxEnding + "CN=CD";
break;
case 69:
case 70:
case 71:
ServerName = "CN=DALEXCBE01";
StorageGroup = "CN=EG" + MailBoxEnding + "CN=EG";
break;
case 72:
case 73:
case 74:
ServerName = "CN=DALEXCBE02";
StorageGroup = "CN=HJ" + MailBoxEnding + "CN=HJ";
break;
case 75:
case 76:
ServerName = "CN=DALEXCBE02";
StorageGroup = "CN=KL" + MailBoxEnding + "CN=KL";
break;
case 77:
case 78:
case 79:
ServerName = "CN=DALEXCBE02";
StorageGroup = "CN=MO" + MailBoxEnding + "CN=MO";
break;
case 80:
case 81:
case 82:
ServerName = "CN=DALEXCBE03";
StorageGroup = "CN=PR" + MailBoxEnding + "CN=PR";
break;
case 83:
ServerName = "CN=DALEXCBE03";
StorageGroup = "CN=S" + MailBoxEnding + "CN=S";
break;
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
ServerName = "CN=DALEXCBE03";
StorageGroup = "CN=TZ" + MailBoxEnding + "CN=TZ";
break;
}

string strServer = @"LDAP://DALADINT01/" + StorageGroup +
",CN=InformationStore," + ServerName +
",CN=Servers,CN=Dallas,CN=Administrative Groups,CN=CROSSMARK,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=Internal, DC=PVT";

try
{
mailbox = (IMailboxStore)oUser.NativeObject;
mailbox.CreateMailbox(strServer);
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}

if (MailBoxEnding == "PT1")
{
oUser.Properties["submissionContLength"].Value = "2000";
oUser.Properties["delivContLength"].Value = "2000";
}

oUser.CommitChanges();

return true;
}
} // End Exchange Class
} // End Namespace


Thanks for any help that yall con provide.

Tim


Jan 16 '06 #1
0 1759

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: warren ali | last post by:
Hi all! I'm new to python and I seem to have a hit a of a brick wall. I hope you guys can help. I'm trying to rewrite some of my vbscripts in python. This particular script connects to a...
6
by: Jason | last post by:
Sorry for the post here but could not find an Exchange newgroup. I developed an application a year or 2 ago that sends SMTP email. The application allows the user to customize the text from...
19
by: steve | last post by:
// What I want to do Use enumerated types with the Interlocked.Exchange methods Suggestions please // My estimation of problem Seems like Interlocked.Exchange only works with ints,...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
2
by: George Durzi | last post by:
We recently upgraded to Exchange2K3/W2K3 from Exchange2K/W2K, and some of my c# code that I used to access users' contacts using WebDAV has stopped working. I'm getting a 401 unauthorized error....
8
by: Michel Posseth [MCP] | last post by:
Hi does someone has experience with this ?? i have made a lot of apps in the past that were capable of sending e-mails the server i then talked to was a Linux SMTP server and it worked great ...
2
by: Doug Raney | last post by:
I am very new to Exchange. I need to have my Exchange server forward a copy of a message to an email address when the subject or body contains a known unique identifier. Where do I start? How can I...
0
by: arjen1984 | last post by:
I am now working on C# with WebDAV on Exchange now to get appointments. When I work local on the domain where the server is, i can get the appointments no problem. When I work outside of it, i get an...
5
by: annCooper | last post by:
Exchange Rates Source file: Exchange.cs Input file: Exchange.in Output file: Exchange.out Using money to pay for goods and services usually makes life easier, but sometimes people prefer to...
2
by: adam.waterfield | last post by:
Maybe someone could help me a little here. On a project I am working on, we have some LDAP authentication to Active Directory which allows users to login to our application - this is fine. When...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.