MailEnable Method
MailEnable Method
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The MailEnable method enables a recipient to receive mail. The recipient can be a user, folder, contact, or group.
Applies To
Type Library
Microsoft CDO for Exchange Management Library
DLL Implemented In
CDOEXM.DLL
Syntax
[Visual Basic]Sub MailEnable
(
ByVal [TargetMailAddress As String]
)
[C++]HRESULT MailEnable ( BSTR TargetMailAddress );
Parameters
- TargetMailAddress
The TargetMailAddress sets the TargetAddress Property.
Return Value
Returns S_OK if successful, or an error value otherwise.
Remarks
The MailEnable method creates the proxy addresses (sets the ProxyAddresses Property, and the SMTPEmail Property and X400Email Property).
MailEnable also sets the TargetAddress Property if the object type is not a group. When the MailEnable method is called with a TargetMailAddress parameter (for a recipient or a contact), it sets the TargetAddress Property.
Example
The following example illustrates the MailEnable method using Collaboration Data Objects (CDO).
[Visual Basic]
Sub MailEnableCDOPerson(strFirstName As String, _ strLastName As String, _ strTargetMailAddress As String)
Dim oPerson As New CDO.Person
Dim oRecipient As CDOEXM.IMailRecipient
Dim strUserName As String
Dim strURL As String
Dim strContainerName As String
Dim forward_email As String
'Target address should look like this
'strTargetMailAddress = strLastName & "@microsoft.com"
strUserName = strFirstName & strLastName
strContainerName = "Users"
' Create URL for the user
CreateUserURL(strURL, strContainerName, False, strUserName)
oPerson.FirstName = strFirstName
oPerson.LastName = strLastName
oPerson.DataSource.SaveTo strURL
Set oPerson = New CDO.Person
' Bind
oPerson.DataSource.Open strURL
' MailEnable
Set oRecipient = oPerson
oRecipient.MailEnable strTargetMailAddress
If oRecipient.TargetAddress = "" And oRecipient.X400Email = "" Then
forward_email = "smtp:" + recipname + "@" + forward_domain
oRecipient.MailEnable forward_email 'where to forward the mail to
oRecipient.IncomingLimit = 50
oRecipient.OutgoingLimit = 50
' Save
oPerson.DataSource.Save
MsgBox recipname + " mail enabled successfully"
Else
MsgBox recipname + " is already mail enabled"
End If
'CleanUp
Set oPerson = Nothing
Set oRecipient = Nothing
End Sub
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.