I have QuickBooks 2010 pro edition, As the Title suggests I need to import Products & Invoices into Quickbooks.
Some Background...
we are an online company where we sell products online, my client wants to import all products into quickbooks and every online sale into quickbooks as well, our website is built using ASP.NET with SQL Server as backed.
I am new to quickbooks, so i am not sure what to do from here...
I have heard of IIF import & SDK, unfortunately I could not find and valuable documentation on them. can anyone please put me in right direction (maybe some sample code)? please do not give me SDK url of quickbooks website.
Thanks
If you're not willing to look at the QuickBooks SDK, you are doing yourself a huge disservice.
The easiest way to implement what you're trying to do is via the SDK and the Web Connector. There's a basic overview of the QuickBooks Web Connector on our wiki. It's specifically geared towards moving data from an online website, into QuickBooks for Windows (just like you're trying to do). The basic idea is that it polls your website, asking for stuff to do, and you can feed it XML requests to do stuff (add a customer, add an invoice, etc.).
Basic protocol looks like this:
// Web Connector asks your SOAP service to authenticate Web Connector
=> SOAP server: authenticate with the username "xyz" and the password "bla" (authenticate)
If authentication is successful, the SOAP server returns a ticket value and the process continues
// Web Connector asks for something to do Web Connector => SOAP
server: hey SOAP server, what do you have for me to do?
(sendRequestXML)
SOAP server generates and returns a qbXML request
// Web Connector relays that request to QuickBooks, and receives a
response from QuickBooks Web Connector => QuickBooks: hey
QuickBooks, the SOAP server gave me this request, can you please
process it?
QuickBooks processes the request, and returns a response to the Web Connector
// Web Connector relays the response from QuickBooks back to the SOAP
server Web Connector => SOAP server: hey SOAP server, here is the
response for that last request from QuickBooks (receiveResponseXML)
SOAP server processes the response, handling any errors and doing whatever with the response
SOAP server returns a percentage done, if it's less than 100%, this process continues...
// The process starts over, with the Web Connector asking the SOAP
server for the next request... Web Connector => SOAP server: hey
SOAP server, what else do you have for me to do? (sendRequestXML)
SOAP server generates and returns a qbXML request
... and so on and so forth ...
If you download the QuickBooks SDK (ouch, sorry!) you'll find that it contains some of the stuff you've asked for. Specifically, there is sample code it drops in this directory:
C:\Program Files (x86)\Intuit\IDN\QBSDK12.0\samples\qbdt\c-sharp\qbXML\WCWebService
Here's a cleaned up, stripped down version of what's in that sample code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.IO;
using System.Security.Cryptography;
using Microsoft.Win32;
using System.Xml;
using System.Text.RegularExpressions;
namespace WCWebService
{
/// <summary>
/// Web Service Namespace="http://developer.intuit.com/"
/// Web Service Name="WCWebService"
/// Web Service Description="Sample WebService in ASP.NET to
/// demonstrate QuickBooks WebConnector"
/// </summary>
[WebService(
Namespace="http://developer.intuit.com/",
Name="WCWebService",
Description="Sample WebService in ASP.NET to demonstrate " +
"QuickBooks WebConnector")]
// Important Note:
// You should keep the namespace as http://developer.intuit.com/ for all web
// services that communicates with QuickBooks Web Connector.
public class WCWebService : System.Web.Services.WebService
{
...
#region WebMethods
[WebMethod]
/// <summary>
/// WebMethod - authenticate()
/// To verify username and password for the web connector that is trying to connect
/// Signature: public string[] authenticate(string strUserName, string strPassword)
///
/// IN:
/// string strUserName
/// string strPassword
///
/// OUT:
/// string[] authReturn
/// Possible values:
/// string[0] = ticket
/// string[1]
/// - empty string = use current company file
/// - "none" = no further request/no further action required
/// - "nvu" = not valid user
/// - any other string value = use this company file
/// </summary>
public string[] authenticate(string strUserName, string strPassword)
{
string[] authReturn = new string[2];
// Code below uses a random GUID to use as session ticket
// An example of a GUID is {85B41BEE-5CD9-427a-A61B-83964F1EB426}
authReturn[0]= System.Guid.NewGuid().ToString();
// For simplicity of sample, a hardcoded username/password is used.
// In real world, you should handle authentication in using a standard way.
// For example, you could validate the username/password against an LDAP
// or a directory server
string pwd="password";
if (strUserName.Trim().Equals("username") && strPassword.Trim().Equals(pwd))
{
// An empty string for authReturn[1] means asking QBWebConnector
// to connect to the company file that is currently openned in QB
authReturn[1]="";
}
else
{
authReturn[1]="nvu";
}
// You could also return "none" to indicate there is no work to do
// or a company filename in the format C:\full\path\to\company.qbw
// based on your program logic and requirements.
return authReturn;
}
[ WebMethod(Description="This web method facilitates web service to send request XML to QuickBooks via QBWebConnector",EnableSession=true) ]
/// <summary>
/// WebMethod - sendRequestXML()
/// Signature: public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
/// string Country, int qbXMLMajorVers, int qbXMLMinorVers)
///
/// IN:
/// int qbXMLMajorVers
/// int qbXMLMinorVers
/// string ticket
/// string strHCPResponse
/// string strCompanyFileName
/// string Country
/// int qbXMLMajorVers
/// int qbXMLMinorVers
///
/// OUT:
/// string request
/// Possible values:
/// - “any_string” = Request XML for QBWebConnector to process
/// - "" = No more request XML
/// </summary>
public string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName,
string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers)
{
... build some qbXML request here and return it ...
return request;
}
[ WebMethod(Description="This web method facilitates web service to receive response XML from QuickBooks via QBWebConnector",EnableSession=true) ]
/// <summary>
/// WebMethod - receiveResponseXML()
/// Signature: public int receiveResponseXML(string ticket, string response, string hresult, string message)
///
/// IN:
/// string ticket
/// string response
/// string hresult
/// string message
///
/// OUT:
/// int retVal
/// Greater than zero = There are more request to send
/// 100 = Done. no more request to send
/// Less than zero = Custom Error codes
/// </summary>
public int receiveResponseXML(string ticket, string response, string hresult, string message)
{
... process the response from QuickBooks here, and return an integer ...
return retVal;
}
#endregion
} // class: WCWebService
} // namespace: WCWebService
The QuickBooks SDK also contains a 98 page Web Connector documentation PDF which describes implementation in detail, and 600 pages of general QuickBooks SDK documentation which might be helpful.
Related
OK, so I am creating a new project in VS2017 for an ASP.Net Core 2.0 API. I have and Azure AD set up and on the wizard to set up a new project, I select Change Authentication and schhose "Work or School accont" then enter the name of my Azure AD (i.e. mycompany.onmicrosoft.com). The project gets created and I can see the addition of this code in the Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));
services.AddMvc();
}
and I can see the settings added to the appSettings.json file
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "mycompany.onmicrosoft.com",
"TenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
Where TenentID is the Directory ID for the Azure AD
and ClientID is the ApplicationID value of the newly created API as it is now registered in the Azure AD.
This all makes sense.
But if I run the project in VS2017 and then navigate to the https://localhost:44348/api/values loc ation, I am getting a 401 Unauthorized.
That part I am missing that I must have to register my https://localhost:44348 browser instance somehow in Azure in order to identify it as the approved client application for my testing. But I am not clear where to do that. Do I just register https://localhost:44348 in the app registration for my Azure AD wor am I supposed to generate a key in the app registration for the Anew API project in Azure AD and pass that key as a secret in my auth header somehow?
What if I wanted to test this using Postman? How would I do that? Do I have to somehow register postman in Azure AD?
I have looked at many Google pages and there are plenty of examples showing how to do interactive login from web pages and then registering that web page sign-in url in Azure AD but not how to do it when simply trying to test an API from VS2017 debug or Postman.
How do I do that?
EDIT - After reading the comments, I created a console application and I registered it in my Azure AD app registrations and created a key. I am providing it here for anyone else that may be trying to understand this process server to server OAUTH2 process.
Credit to this GitHub repo for help in the code design below;
Here is the console application code
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Configuration;
using System.Globalization;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace API.TestConsole
{
class Program
{
/// <summary>
/// The AAD Instance is the instance of Azure.
/// </summary>
/// <remarks>
/// Example: https://login.microsoftonline.com/{0}
/// </remarks>
private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"];
/// <summary>
// The Tenant is the Directory ID of the Azure AD tenant in which this application is registered.
/// </summary>
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"];
/// <summary>
/// The Client ID is used by this application to uniquely identify itself to Azure AD.
/// </summary>
/// <remarks>
/// This value is obtained when this application is registered in Azure AD
/// </remarks>
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
/// <summary>
// The App Key is a credential used by this application to authenticate to Azure AD.
/// </summary>
/// <remarks>
/// This value is generated when this application is registered in Azure AD and assigned a key
/// </remarks>
private static string appKey = ConfigurationManager.AppSettings["ida:AppKey"];
/// <summary>
// The Authority is the sign-in URL of the tenant.
/// </summary>
/// <remarks>
/// This is a string combination of the aadInstance and the tenant
/// </remarks>
static string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant);
/// <summary>
/// The ApplicationID of the evsApi service in Azure
/// </summary>
private static string apiResourceId = ConfigurationManager.AppSettings["api:ApiResourceId"];
/// <summary>
/// The base URL address of the Api service
/// </summary>
private static string apiBaseAddress = ConfigurationManager.AppSettings["api:ApiBaseAddress"];
private static HttpClient httpClient = new HttpClient();
private static AuthenticationContext authContext = null;
private static ClientCredential clientCredential = null;
static void Main(string[] args)
{
// As a test, call the test Api, values endpoint 10 times with a short delay between calls
authContext = new AuthenticationContext(authority);
clientCredential = new ClientCredential(clientId, appKey);
for (int i = 0; i < 10; i++)
{
Thread.Sleep(3000);
GetValues().Wait();
}
Console.WriteLine("Press ENTER to exit.");
Console.ReadLine();
}
static async Task GetValues()
{
// Get an access token from Azure AD using client credentials.
// If the attempt to get a token fails because the server is unavailable, retry twice after 3 seconds each.
AuthenticationResult result = null;
int retryCount = 0;
bool retry = false;
do
{
retry = false;
try
{
// ADAL includes an in memory cache, so this call will only send a message to the server if the cached token is expired.
result = await authContext.AcquireTokenAsync(apiResourceId, clientCredential);
}
catch (AdalException ex)
{
if (ex.ErrorCode == "temporarily_unavailable")
{
retry = true;
retryCount++;
Thread.Sleep(3000);
}
Console.WriteLine(
String.Format($"An error occurred while acquiring a token\nTime: " +
$"{DateTime.Now.ToString()}\nError: {ex.ToString()}\nRetry: {retry.ToString()}\n"));
}
} while ((retry == true) && (retryCount < 3));
if (result == null)
{
Console.WriteLine("Canceling attempt to contact the test API service.\n");
return;
}
// Add the access token to the authorization header of the request.
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
// Call the values endpoint in the test API service. This is an HTTP GET.
Console.WriteLine("Retrieving values from Values endpoint at {0}", DateTime.Now.ToString());
HttpResponseMessage response = await httpClient.GetAsync(apiBaseAddress + "/api/values");
if (response.IsSuccessStatusCode)
{
// Read the response and output it to the console.
string s = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Values Result: {s}\n");
}
else
{
Console.WriteLine("Failed to retrieve Values\nError: {0}\n", response.ReasonPhrase);
}
}
}
}
And here is the App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="ida:AADInstance" value="https://login.microsoftonline.com/{0}" />
<!-- This is the Directory ID value of the Azure AD -->
<add key="ida:Tenant" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
<!-- This is the Application ID value of this test console application as it is
registered in the Azure AD app registration in the portal directory -->
<add key="ida:ClientId" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
<!-- This is the Key value of this test console application, as it is
generated in the keys section for "Test Console Key" in the Azure AD app registration
for this test console application in the portal directory -->
<add key="ida:AppKey" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<!-- This is the Application ID value of the test api application as it is
registered in the Azure AD app registration in the portal directory -->
<add key="api:apiResourceId" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
<!-- This is the custom domain URL assigned to the test app service in the Azure
portal -->
<add key="api:apiBaseAddress" value="https://testapi.mycompany.com" />
</appSettings>
</configuration>
Put simply, you need an access token.
How do you get an access token? Through an authentication flow like OAuth Client Credentials: https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-service-to-service.
Or you might need to use OpenID Connect: https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-openid-connect-code.
Client credentials will make the call as an app, while OIDC (and some other flows) allows you to call the API as a user.
You will have to call as a user unless you add some permissions: https://joonasw.net/view/defining-permissions-and-roles-in-aad
Anyway, you will have to register the app that will call the API, and give it access to the API.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am currently looking into (ideally headless) integration testing frameworks for asp.net mvc 5 (potentially with webapi in the same project). I am aware of these 2:
SpecsFor.Mvc
MvcIntegrationTestFramework (there are several incarnation of this on github)
Are there any others? I am especially interested in any frameworks that work well with specflow.
I successfully integrated SpecsFor.Mvc with SpecFlow today. It's pretty cool.
Here's a set of classes that should get you started with integrating SpecsFor.Mvc with SpecFlow. Of course, these could be better abstracted and extended upon; but at a bare minimum, this is all you need:
namespace SpecsForMvc.SpecFlowIntegration
{
using Microsoft.VisualStudio.TestingTools.UnitTesting;
using SpecsFor.Mvc;
using TechTalk.SpecFlow;
[Binding]
public class SpecsForMvcSpecFlowHooks
{
private static SpecsForIntegrationHost integrationHost;
/// <summary>
/// <p>
/// This hook runs at the end of the entire test run.
/// It's analogous to an MSTest method decorated with the
/// <see cref="Microsoft.VisualStudio.TestingTools.UnitTesting.AssemblyCleanupAttribute" />
/// attribute.
/// </p>
/// <p>
/// NOTE: Not all test runners have the notion of a test run cleanup.
/// If using MSTest, this probably gets run in a method decorated with
/// the attribute mentioned above. For other test runners, this method
/// may not execute until the test DLL is unloaded. YMMV.
/// </p>
/// </summary>
[AfterTestRun]
public void CleanUpTestRun()
{
integrationHost.Shutdown();
}
/// <summary>
/// <p>
/// This hook runs at the beginning of an entire test run.
/// It's equivalent to an MSTest method decorated with the
/// <see cref="Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyInitializeAttribute />
/// attribute.
/// </p>
/// <p>
/// NOTE: Not all test runners have a notion of an assembly
/// initializer or test run initializer, YMMV.
/// </p>
/// </summary>
[BeforeTestRun]
public static void InitializeTestRun()
{
var config = new SpecsForMvcConfig();
config.UseIISExpress()
.With(Project.Named("Your Project Name Here"))
.ApplyWebConfigTransformForConfig("Debug");
config.BuildRoutesUsing(r => RouteConfig.RegisterRoutes(r));
// If you want to be authenticated for each request,
// implement IHandleAuthentication
config.AuthenticateBeforeEachTestUsing<SampleAuthenticator>();
// I originally tried to use Chrome, but the Selenium
// Chrome WebDriver, but it must be out of date because
// Chrome gave me an error and the tests didn't run (NOTE:
// I used the latest Selenium NuGet package as of
// 23-08-2014). However, Firefox worked fine, so I used that.
config.UseBrowser(BrowserDriver.Firefox);
integrationHost = new SpecsForMvcIntegrationHost(config);
integrationHost.Start();
}
/// <summary>
/// This hook runs once before any of the SpecFlow feature's
/// scenarios are run and stores a <see cref="SpecsFor.Mvc.MvcWebApp />
/// instance in the <see cref="TechTalk.SpecFlow.FeatureContext" />
/// for the feature.
/// </summary>
[BeforeFeature]
public static void CreateFeatureMvcWebApp()
{
MvcWebApp theApp;
if (!FeatureContext.Current.TryGetValue<MvcWebApp>(out theApp))
FeatureContext.Current.Set<MvcWebApp>(new MvcWebApp());
}
}
public class SpecsForMvcStepDefinitionBase
{
/// <summary>
/// Gets the instance of the <see cref="SpecsFor.Mvc.MvcWebApp" />
/// object stored in the <see cref="TechTalk.SpecFlow.FeatureContext" />
/// for the current feature.
/// </summary>
public static MvcWebApp WebApp
{
get { return FeatureContext.Current.Get<MvcWebApp>(); }
}
}
}
Then, let's say you have a SpecFlow feature file as per the below (this is a partial file):
Feature: Login
As a user of the website
I want to be able to log on the the site
in order to use the features available to site members.
# For the site I'm currently working with, even though it's MVC, it's more
# of a WebAPI before there was WebAPI--so the controllers accept JSON and return
# JsonResult objects--so that's what you're going to see.
Scenario: Using a valid username and password logs me on to the site
Given the valid username 'somebody#somewhere.com'
And the password 'my_super_secure_password'
When the username and password are submitted to the login form
Then the website will return a result
And it will contain an authentication token
And it will not contain any exception record.
And now the steps for the above scenario:
using Newtonsoft.Json;
using OpenQA.Selenium;
using MyWebSite.Controllers;
using Should;
using TechTalk.SpecFlow;
[Binding]
public class LoginSteps : SpecsForMvcStepDefinitionBase
{
// The base class gets me the WebApp property that allows easy
// access to the SpecsFor.Mvc.MvcWebApp object that drives a web browser
// via Selenium.
private string _username;
private string _password;
private string _portalSessionId;
private ServiceResponse<LoginSummary> _loginResponse;
[Given(#"the valid username '(.*)'")]
[Given(#"the invalid username '(.*)'")]
public void GivenAUsername(string username)
{
_username = username;
}
[Given(#"the valid password '(.*)'")]
[Given(#"the invalid password '(.*)'")]
public void GivenAPassword(string password)
{
_password = password;
}
[When(#"the username and password are submitted to the " +
#"LoginUser action method of the UserController")]
public void WhenTheUsernameAndPasswordAreSubmitted()
{
WebApp.NavigateTo<UserController>(
c => c.LoginUser(_username, _password)
);
}
[Then(#"the UserController will reply with a LoginSummary")]
public void ThenTheUserControllerWillReplyWithALoginSummary()
{
_loginResponse =
JsonConvert.DeserializeObject<ServiceResponse<LoginSummary>>(
WebApp.Browser.FindElement(By.TagName("pre")).Text
);
}
[Then(#"it will contain an authentication token")]
public void ThenItWillContainAnAuthenticationToken()
{
_loginSummary.Results.Count.ShouldBeGreaterThan(0);
_loginSummary.Results[0].AuthenticationToken.ShouldNotBeEmpty();
}
[Then(#"it will not contain an exception record")]
public void THenItWillNotContainAnExceptionRecord()
{
_loginSummary.Exception.ShouldBeNull();
}
}
Pretty cool.
About the methods decorated with BeforeTestRun and AfterTestRun, I found the information mentioned in the code comments at the following blog post: Advanced SpecFlow: Using Hooks to Run Additional Automation Code.
Of course, you may still want to construct classes that follow the Page Object pattern if you'll be testing presentation layout. As I stated in my code comments, the particular app I'm writing integration tests for pre-dates WebAPI but function like WebAPI but using ASP.Net MVC. We just haven't officially ported it to WebAPI yet.
I am using SingalR for my Chat Application. Wanted to play with Redis
and SignalR but I cannot find an working example where i can send msg to
specific connectionId. Below Code that works for a single server instance.
But when i make it a Web Garden with 3 process it stops working as my
server instance that gets the message cannot find the connectionId
for that destination UserId to send the message.
private readonly static ConnectionMapping<string> _connections = new ConnectionMapping<string>();
public void Send(string sendTo, string message, string from)
{
string fromclientid = Context.QueryString["clientid"];
foreach (var connectionId in _connections.GetConnections(sendTo))
{
Clients.Client(connectionId).send(fromclientid, message);
}
Clients.Caller.send(sendTo, "me: " + message);
}
public override Task OnConnected()
{
int clientid = Convert.ToInt32(Context.QueryString["clientid"]);
_connections.Add(clientid.ToString(), Context.ConnectionId);
}
I have used the example below to setup my box and code but none of
them have examples for sending from one client to specific client or
group of specific clients.
http://www.asp.net/signalr/overview/performance-and-scaling/scaleout-with-redis
https://github.com/mickdelaney/SignalR.Redis/tree/master/Redis.Sample
The ConnectionMapping instance in your Hub class will not synced across different SignalR server instances. You need to use permanent external storage such as a database or a Windows Azure table. Refer to this link for more details:
http://www.asp.net/signalr/overview/hubs-api/mapping-users-to-connections
I have made asp.net mvc application that have custom forms authentication.
Beside that it needs to authenticate user from sharepoint (in other words I need to pass user from sharepoint to asp mvc application). SP and asp mvc app are in the same domain and SP is using AD to authenticate user. I have searched google/so and so far I haven`t got any good solution.
Note: I need secure way of passing user from sp to asp mvc application ... I saw few examples that pass user thought URL parameter and I think that this is not secure thing to do.
Why not to use url paramenter?
public class SecureToken {
public Int32 UserId {get;set;}
public DateTime DateCreated {get;set;}
public DateTime ValidTill {get;set;}
public SecureToken (Int32 userId) {
this.UserId = userId;
this.DateCreated = DateTime.Now;
this.ValidTill = this.DateCreated.AddMinutes(0.5);
}
public String ToEncryptedToken() {
// Do serialization,
// Then encrypt with, for example TrippleDES
// Escape for url
// return the string arguement for url
}
public static SecureToken Decrypt(String input) {
// If the DateCreated == ValidTill - 30 seconds
// If validTill > Now
// If decryptable
// Return deserialized token
// else throw Authentication error.
}
}
The point here is that the token while in URL is viable only for 30 seconds.
As an additional parameter you can use HMAC-SHA 256 during serialization and check weather this is really your token.
You could configure SP for a custom forms auth provider which in turn validates to the domain - then you are sharing forms auth tokens between apps which is fairly easy:
http://msdn.microsoft.com/en-us/library/ie/eb0zx8fc.aspx
I found this web part for Exchange 2003, but in exchange 2007 even after user login, web part shows exchange 2007 owa login page (instead of current user inbox).
How I can show current user's exchange 2007 inbox in moss 2007? Any Idea?
The solution is to create a wrapper webpart around the out of the box OWA webpart and have that access the inbox by using the currently logged in user's emailaddress.
Here's the code
P.S. (note that the address of the webaccess is set in the appsettings here!)
using System;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Portal.WebControls;
namespace DCubed.SharePoint.WeParts
{
/// <summary>
/// Wrapper around the My Inbox WebPart
/// </summary>
public class MyInboxEx : WebPart
{
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
// Create the instance of My Inbox Web Part
var inbox = new OWAInboxPart
{
MailboxName = SPContext.Current.Web.CurrentUser.Email,
OWAServerAddressRoot = ConfigurationManager.AppSettings["MailServer"]
};
Controls.Add(inbox);
}
}
}