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.

116 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />

StarCommunity.Modules.Webmail is 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 />

Creating the Account<br />

To create the account, we get the User for which the account is to be created, and then call the AddMailAccount<br />

method in the WebmailHandler, specifying the local part of the address (the part before the “@” sign) to be associated<br />

with the new account. Optionally you can also supply a Domain. If no domain is supplied, the one set in the<br />

configuration file is used as the default.<br />

Domain domain = WebmailHandler.GetDomainByDomainName("my.domain");<br />

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

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

WebmailHandler.AddMailAccount(user, "address.part", domain);<br />

The account is now created on the mail server, and incoming messages to this address will be accepted from this point<br />

on.<br />

It is important to note that the local part of the address has to be unique; it is therefore a good idea to think of some<br />

means of making sure that collisions will not occur. For instance, the <strong>EPiServer</strong> Community username may be used (as<br />

that is known to be unique), provided that it does not contain any illegal characters.<br />

2.28.3 Disabling, Reactivating and Permanently Removing Accounts<br />

It may be of interest to disable an account for different reasons or to remove an account entirely.<br />

For instance, the mail account may be a premium service, which should be disabled if the user stops paying. Another<br />

example may be a misbehaving user that should have their account removed.<br />

Keep in mind that when a <strong>EPiServer</strong> Community user is soft-removed, reactivated or permanently removed, these<br />

changes also reflect on the user’s mail account automatically, if there is one.<br />

© <strong>EPiServer</strong> AB

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

Saved successfully!

Ooh no, something went wrong!