31.10.2014 Views

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tutorials | 115<br />

2.28 Webmail<br />

Webmail management in <strong>EPiServer</strong> Community is done through the WebmailHandler class in the<br />

StarCommunity.Webmail namespace.This article shows you, the developer, examples of how to add Webmail<br />

functionality to a community site with the help of the <strong>EPiServer</strong> Community Framework.<br />

2.28.1 Getting the status of an account<br />

It is essential to know whether a user has a mail account, and if so, that it is active.<br />

Import Necessary Namespaces<br />

First, import the necessary namespaces that will be needed. The namespaces StarCommunity.Core,<br />

StarCommunity.Core.Modules.Security and StarCommunity.Modules.VideoGallery<br />

The StarCommunity.Modules.VideoGallery namespace contains classes for creating video galleries and uploading videos<br />

for transcoding into a web friendly format, like Adobe Flash Video.<br />

StarCommunity.Modules.Webmail are described by clicking on their respective names. Make sure you also add the<br />

mentioned assemblies as references, as mentioned in section 1.1.1.<br />

using StarCommunity.Core;<br />

using StarCommunity.Core.Modules.Security;<br />

using StarCommunity.Modules.Webmail;<br />

Getting the Account for a User and the Status of that Account<br />

First we get the desired User object, then the MailAccount for that user, and from the account, we can then get the<br />

MailAccountStatus.<br />

IUser user = (IUser)StarCommunitySystem.<br />

CurrentContext.DefaultSecurity.GetUser(17);<br />

MailAccount account = WebmailHandler.GetMailAccount(user);<br />

MailAccountStatus status = WebmailHandler.GetMailAccountStatus(account);<br />

MailAccountStatus itself is an enum with the values Active, Deactivated and DoesNotExist. This way you can tell if there<br />

is an account, and if so, if it is active or not.<br />

2.28.2 Creating an account<br />

For a site member to be able to receive e-mail, they need to have an account as well as an address associated with that<br />

account. If a user does not already have an account, one will need to be created.<br />

Import Necessary Namespaces<br />

First, import the necessary namespaces that will be needed. The namespaces StarCommunity.Core,<br />

StarCommunity.Core.Modules.Securityand StarCommunity.Modules.VideoGallery<br />

The StarCommunity.Modules.VideoGallery namespace contains classes for creating video galleries and uploading videos<br />

for transcoding into a web friendly format, like Adobe Flash Video.<br />

© <strong>EPiServer</strong> AB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!