Some support VBA functions for mailenable mail server
ActiveX RegEdit.   ActiveX User account Manager   Pure-ASP Upload
Export MDB/DBF from ASP   Active LogFile   WebChecker   ActiveX/ASP Multi Dictionary object
 See 
 also 
 IISTracer, real-time IIS monitor and logging tool.
 Huge ASP file upload with progress bar. 



Do you like this article?
Please, rate it
and write review!
Rated:
by Aspin.com users
What do you think?
 Top messages
 22.3.2003 19:18:41 
 Read and write SQL image data, store binary file to sql table. (nbsp;WSHDatabaseConversionVBScript)
 4.5.2002 9:16:43 
 Send an email from ASP (WSH) using VBSscript, CDONTS and Outlook. (nbsp;ASP / ASP.NetWSHVBScriptEmail)
 10.2.2005 
 Add an email account to a windows 2003 pop3 service using script (nbsp;VBAEmail)
 19.3.2005 
 Batch change of ID3 tags by VB Script in MP3 and other files. (nbsp;VBScriptSound)

 Some support VBA functions for mailenable mail server 

 Areas>VBA
 Areas>ASP / ASP.Net>Email
Option Explicit

'Add functions - add one email address.
' adds postoffice, mailbox, login And maps email address
Public Function AddFullEmail(ByRef Email As String, _
  ByRef Password As String) As Long
  
  Dim UserName As String, Domain As String
  Domain = Split(Email, "@")(1)
  UserName = Split(Email, "@")(0)

  Dim result As Long
  result = CreatePostOffice(Domain)
  If result <> 0 Then result = AddDoaminToPostOffice(Domain)
  If result <> 0 Then result = AddMailBoxToPostOffice(Domain, UserName)
  If result <> 0 Then result = AddLogin(Domain, UserName, Password)
  If result <> 0 Then result = AddEmail(Domain, UserName, Email)
  AddFullEmail = result
End Function

Function CreatePostOffice(ByRef name As String) As Long
  Dim lResult As Long
  Dim PostOffice As New MEAOPO.PostOffice
  'Set PostOffice = CreateObject("MEAOPO.Postoffice")
  
  With PostOffice
    .name = name
    .Host = name
    .Account = name
    .Status = 1
    'Try To get existing postoffice
    lResult = .GetPostoffice()
    If lResult = 0 Then 'create the postoffice
      lResult = .AddPostoffice()
    Else 'Postoffice already exists.
      lResult = -1
    End If
  End With
  CreatePostOffice = lResult
End Function

'Adds domain To postoffice
Function AddDoaminToPostOffice(ByRef PostOffice As String, _
  Optional ByVal DomainName As String = "") As Long
  If Len(DomainName) = 0 Then DomainName = PostOffice
  
  Dim lResult As Long
  Dim oDomain As New MEAOSM.Domain
  'Set oDomain = CreateObject("MEAOSM.Domain")
  
  With oDomain
    .AccountName = PostOffice
    .DomainName = DomainName
    .Status = 1
    'try To get existing domain.
    lResult = .GetDomain
    If lResult = 0 Then 'create the postoffice
      lResult = .AddDomain
    Else 'Postoffice already exists.
      lResult = -1
    End If
  End With
  AddDoaminToPostOffice = lResult
End Function
          

'Adds mailbox To postoffice
Function AddMailBoxToPostOffice(ByRef PostOffice As String, _
  ByRef UserName As String, _
  Optional ByVal Limit As Long = -1) As Long
  
  
  Dim lResult As Long
  Dim oMailbox As New MEAOPO.Mailbox
  'Set oMailbox = CreateObject("MEAOPO.Mailbox")

  With oMailbox
    .PostOffice = PostOffice
    .Mailbox = UserName
    .RedirectAddress = ""
    .RedirectStatus = 0
    .Status = 1
    
    'try To get existing Mailbox.
    lResult = .GetMailbox
    If lResult = 0 Then 'create the Mailbox
      .Limit = Limit
      lResult = .AddMailbox()
    Else 'Mailbox already exists.
      lResult = -1
    End If
  End With
  AddMailBoxToPostOffice = lResult
End Function
      
      
'Adds Login To postoffice
Function AddLogin(ByRef PostOffice As String, _
  ByRef UserName As String, ByRef Password As String) As Long
  
  
  Dim lResult As Long
  Dim oAUTHLogin As New MEAOAU.Login
  'Set oAUTHLogin = CreateObject("MEAOAU.Login")

  'when we create a mailbox we also create a pop logon
  With oAUTHLogin
    .Account = PostOffice
    .UserName = UserName & "@" & PostOffice
    .Status = 1
    .Description = ""
    .Host = ""
    .Rights = "USER"
    
    'try To get existing login.
    lResult = .GetLogin()
    If lResult = 0 Then 'create the login
      .Password = Password
      lResult = .AddLogin()
    Else 'login already exists.
      lResult = -1
    End If
  End With
  AddLogin = lResult
End Function
      
'Adds domain To postoffice
Function AddEmail(ByRef PostOffice As String, _
  ByRef UserName As String, ByRef Email As String) As Long
  
  Dim lResult As Long
  Dim oAddressMap As New MEAOAM.AddressMap
'  Set oAddressMap = CreateObject("MEAOAM.AddressMap")

  With oAddressMap
    Dim varTemp
    
    .Account = PostOffice
    .DestinationAddress = "[SF:" & PostOffice & "/" & UserName & "]"
    .Scope = "[SMTP:" & Email & "]"
    .SourceAddress = "[SMTP:" & Email & "]"
    
    'try To get existing email address.
    lResult = .GetAddressMap
    If lResult = 0 Then 'create a new email address map
      lResult = .AddAddressMap()
    Else 'email address already exists.
      lResult = -1
    End If
  End With
  AddEmail = lResult
End Function
      





'****************** control functions **********************
'retrieves a password from an email address (username@postoffice)
Public Function GetPassword(ByRef Email As String) As String
  Dim oLogin
  Set oLogin = GetoLogin("" & Split(Email, "@")(1), _
    "" & Split(Email, "@")(0))
  GetPassword = oLogin.Password
End Function

'checks If the login/account is created.
Public Function ExistsLogin(ByRef Email As String) As Boolean
  ExistsLogin = IsObject(GetoLogin("" & Split(Email, "@")(1), _
    "" & Split(Email, "@")(0)))
End Function

'Returns a login object
Function GetoLogin(ByRef PostOffice As String, _
  ByRef UserName As String)
  
  Dim lResult As Long
  Dim oAUTHLogin As New MEAOAU.Login
  'Set oAUTHLogin = CreateObject("MEAOAU.Login")

  With oAUTHLogin
    .Account = PostOffice
    .UserName = UserName & "@" & PostOffice
    .Status = 1
    .Description = ""
    .Host = ""
    .Rights = "USER"
    
    'try To get existing login.
    lResult = .GetLogin()
    If lResult <> 0 Then 'create the login
      Set GetoLogin = oAUTHLogin
    End If
  End With
End Function

'checks If the email address is mapped To an account.
Public Function ExistsEmail(ByRef Email As String) As Boolean
  Dim lResult As Long
  Dim oAddressMap As New MEAOAM.AddressMap
'  Set oAddressMap = CreateObject("MEAOAM.AddressMap")
  
  Dim PostOffice As String
  PostOffice = Split(Email, "@")(1)
  With oAddressMap
    Dim varTemp
    
    .Account = PostOffice
    .SourceAddress = "[SMTP:" & Email & "]"
    
    'try To get existing address.
    lResult = .GetAddressMap
    ExistsEmail = lResult <> 0
  End With
End Function

 
 

See also for 'Some support VBA functions for mailenable mail server' article:

     Check if a pop3 email account exists in a windows 2003 pop3 service Let's you check if a pop3 user email account exists in a windows 2003 pop3 service
     Add an email account to a windows 2003 pop3 service using script Let's you add pop3 user account to a windows 2003 pop3 service using script (VBScript) or Visual basic from WSH, ASP, office or ASP.Net.

If you like this page, please include next link on your pages:
<A
 Href="http://www.motobit.com/tips/detpg_mailenable-support/"
 Title="Lets you create postoffice, mailboxes, logins,
  email adresses from VBA or
  VBScript."
>Some support VBA functions for mailenable mail server</A>

     IISTracer - IIS ISAPI real-time monitor IISTracer is a real-time monitoring tool for Microsoft IIS, which will show/log you what is happenning on IIS server right now. It let's you reveal problems with long-running scripts (.asp, .cgi, cfm...), hang-up states and low resource situations and lets you stop long-running requests (uploads/downloads).      ActiveX User account Manager - Set of simple objects for creating, deleting, and managing user accounts, groups, servers and domains in the Windows NT environment.
     Active log file - Hi-performance text file logging for ASP/VBS/VBA applications. Lets you create daily/weekly/monthly log files with variable number of logged values and extra timing and performance info.      ActiveX windows registry editor - Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.
     ActiveX/ASP Multi Dictionary object - Free-threaded hi-speed dictionary algorithm with unique/nonunique keys (map/multimap). Connect to another dictionary object in the same process. Lock and Unlock methods to synchronize tasks (application scope). Share ASP Application/Session objects.      Export DBF/MDB from ASP - Conversion from recordset to MDB/DBF. Direct binary output of MDB or DBF files from ASP pages with one row of code.
     Pure-ASP upload - lets you upload files using Pure ASP VBS code (using multipart/form-data and input type=file).      ByteArray - Works with safearray binary data (VT_UI1 | VT_ARRAY) - save/restore binary data from disk, find, work with code pages, convert to string/hexstring(SQL).
     WebChecker - Checks http, https, ftp and gopher internet connections in regular intervals. Lets you monitor web site functionality (uptime). Enables restart or notification on problems.      HTTPLog ISAPI filter - Lets you log incomming/outgoing http header and document data to separate files. Monitor of IIS service input/output.

© 1996 – 2008 Antonin Foller, PSTRUH Software, e-mail help@pstruh.cz