barkebn Absent Member.
Absent Member.
2275 views

How to Create a Rule in VB

Can anyone help me with creating a rule using Visual Basic 6?

What I am trying to do is create a SPAM folder and then create a rule for incoming mail to redirect it to the SPAM folder. Here's the code I use to create the folder:

Option Explicit

' Add reference to Groupware Type Library

Private Sub Form_Load()
Me.Caption = Me.Caption & ", v" & App.Major & "." & App.Minor

Dim ogwApplication As GroupwareTypeLibrary.Application
Dim ogwRootAccount As GroupwareTypeLibrary.Account
Dim ogwFolder As Folder
Dim strCommandOptions As String

Dim strLoginName As String
Dim strMailPassword As String
Dim strFolderToSearch As String
Dim strFolderToAdd As String
Dim bFoundIt As Boolean

strLoginName = "barkebn"
strFolderToSearch = "Cabinet"
strFolderToAdd = "SPAM Folder"

Set ogwApplication = CreateObject("NovellGroupWareSession")

' Create connection/login to email account '
If ogwRootAccount Is Nothing Or Len(strLoginName) <> 0 Then ' Need to log in '
' Login to root account '
If Len(strMailPassword) Then ' Password was passed, so use it '
strCommandOptions = "/pwd=" & strMailPassword
Else ' Password was not passed '
strCommandOptions = vbNullString
End If

Set ogwRootAccount = ogwApplication.Login(strLoginName, strCommandOptions, , egwPromptIfNeeded)
End If

' Look for the folder. If it doesn't exist, create it '
bFoundIt = False
For Each ogwFolder In ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders
If ogwFolder.Name = strFolderToAdd Then
bFoundIt = True
End If
Next ogwFolder

If bFoundIt = False Then
ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders.Add (strFolderToAdd)
End If

' Release all objects before closing '
Set ogwRootAccount = Nothing
Set ogwApplication = Nothing

MsgBox "Done." & vbNewLine & "To see the new folder if Groupwise is already running," & vbNewLine & "put the mouse on the Cabinet folder and press F5.", vbInformation, "Folder created."
End Sub


What do I need to do next?
Labels (1)
0 Likes
3 Replies
Anonymous_User Absent Member.
Absent Member.

Re: How to Create a Rule in VB

There are problems with rules in the Object API.
Your only options for now is to use the SOAP API
to configure rules.

Preston


>>> On Tuesday, April 27, 2010 at 10:46 AM,

barkebn<barkebn@no-mx.forums.novell.com> wrote:

> Can anyone help me with creating a rule using Visual Basic 6?
>
> What I am trying to do is create a SPAM folder and then create a rule
> for incoming mail to redirect it to the SPAM folder. Here's the code I
> use to create the folder:
>
> Option Explicit
>
> ' Add reference to Groupware Type Library
>
> Private Sub Form_Load()
> Me.Caption = Me.Caption & ", v" & App.Major & "." & App.Minor
>
> Dim ogwApplication As GroupwareTypeLibrary.Application
> Dim ogwRootAccount As GroupwareTypeLibrary.Account
> Dim ogwFolder As Folder
> Dim strCommandOptions As String
>
> Dim strLoginName As String
> Dim strMailPassword As String
> Dim strFolderToSearch As String
> Dim strFolderToAdd As String
> Dim bFoundIt As Boolean
>
> strLoginName = "barkebn"
> strFolderToSearch = "Cabinet"
> strFolderToAdd = "SPAM Folder"
>
> Set ogwApplication = CreateObject("NovellGroupWareSession")
>
> ' Create connection/login to email account '
> If ogwRootAccount Is Nothing Or Len(strLoginName) <> 0 Then '
> Need to log in '
> ' Login to root account '
> If Len(strMailPassword) Then ' Password was passed, so use it
> '
> strCommandOptions = "/pwd=" & strMailPassword
> Else ' Password was not passed '
> strCommandOptions = vbNullString
> End If
>
> Set ogwRootAccount = ogwApplication.Login(strLoginName,
> strCommandOptions, , egwPromptIfNeeded)
> End If
>
> ' Look for the folder. If it doesn't exist, create it '
> bFoundIt = False
> For Each ogwFolder In
> ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders
> If ogwFolder.Name = strFolderToAdd Then
> bFoundIt = True
> End If
> Next ogwFolder
>
> If bFoundIt = False Then
>
> ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders.Add
> (strFolderToAdd)
> End If
>
> ' Release all objects before closing '
> Set ogwRootAccount = Nothing
> Set ogwApplication = Nothing
>
> MsgBox "Done." & vbNewLine & "To see the new folder if Groupwise is
> already running," & vbNewLine & "put the mouse on the Cabinet folder and
> press F5.", vbInformation, "Folder created."
> End Sub
>
>
> What do I need to do next?

0 Likes
barkebn Absent Member.
Absent Member.

Re: How to Create a Rule in VB

Understood. Thank you for responding.

Is there sample code? How do I do that (or at least, how do I get started)? I've searched both here and in the SOAP API section, as well as the rest of the internet. There are similar requests but no responses as to how to create a rule.

------------------------------------------------------------------------
Preston Stephenson;1967662 wrote:
There are problems with rules in the Object API.
Your only options for now is to use the SOAP API
to configure rules.

Preston


>>> On Tuesday, April 27, 2010 at 10:46 AM,

barkebn<barkebn@no-mx.forums.novell.com> wrote:

> Can anyone help me with creating a rule using Visual Basic 6?
>
> What I am trying to do is create a SPAM folder and then create a rule
> for incoming mail to redirect it to the SPAM folder. Here's the code I
> use to create the folder:
>
> Option Explicit
>
> ' Add reference to Groupware Type Library
>
> Private Sub Form_Load()
> Me.Caption = Me.Caption & ", v" & App.Major & "." & App.Minor
>
> Dim ogwApplication As GroupwareTypeLibrary.Application
> Dim ogwRootAccount As GroupwareTypeLibrary.Account
> Dim ogwFolder As Folder
> Dim strCommandOptions As String
>
> Dim strLoginName As String
> Dim strMailPassword As String
> Dim strFolderToSearch As String
> Dim strFolderToAdd As String
> Dim bFoundIt As Boolean
>
> strLoginName = "barkebn"
> strFolderToSearch = "Cabinet"
> strFolderToAdd = "SPAM Folder"
>
> Set ogwApplication = CreateObject("NovellGroupWareSession")
>
> ' Create connection/login to email account '
> If ogwRootAccount Is Nothing Or Len(strLoginName) <> 0 Then '
> Need to log in '
> ' Login to root account '
> If Len(strMailPassword) Then ' Password was passed, so use it
> '
> strCommandOptions = "/pwd=" & strMailPassword
> Else ' Password was not passed '
> strCommandOptions = vbNullString
> End If
>
> Set ogwRootAccount = ogwApplication.Login(strLoginName,
> strCommandOptions, , egwPromptIfNeeded)
> End If
>
> ' Look for the folder. If it doesn't exist, create it '
> bFoundIt = False
> For Each ogwFolder In
> ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders
> If ogwFolder.Name = strFolderToAdd Then
> bFoundIt = True
> End If
> Next ogwFolder
>
> If bFoundIt = False Then
>
> ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders.Add
> (strFolderToAdd)
> End If
>
> ' Release all objects before closing '
> Set ogwRootAccount = Nothing
> Set ogwApplication = Nothing
>
> MsgBox "Done." & vbNewLine & "To see the new folder if Groupwise is
> already running," & vbNewLine & "put the mouse on the Cabinet folder and
> press F5.", vbInformation, "Folder created."
> End Sub
>
>
> What do I need to do next?
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: How to Create a Rule in VB

What more do you need beside what is in the "Creation of a Rule"
thread in the novell.devsup.gwsoap forum from January?

>>> On Thursday, April 29, 2010 at 4:46 AM,

barkebn<barkebn@no-mx.forums.novell.com> wrote:

> Understood. Thank you for responding.
>
> Is there sample code? How do I do that (or at least, how do I get
> started)? I've searched both here and in the SOAP API section, as well
> as the rest of the internet. There are similar requests but no
> responses as to how to create a rule.
>
>

‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑â
€‘‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑â€
‘‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
> Preston Stephenson;1967662 Wrote:
>> There are problems with rules in the Object API.
>> Your only options for now is to use the SOAP API
>> to configure rules.
>>
>> Preston
>>
>>
>> >>> On Tuesday, April 27, 2010 at 10:46 AM,

>> barkebn<barkebn@no‑mx.forums.novell.com> wrote:
>>
>> > Can anyone help me with creating a rule using Visual Basic 6?
>> >
>> > What I am trying to do is create a SPAM folder and then create a

>> rule
>> > for incoming mail to redirect it to the SPAM folder. Here's the code

>> I
>> > use to create the folder:
>> >
>> > Option Explicit
>> >
>> > ' Add reference to Groupware Type Library
>> >
>> > Private Sub Form_Load()
>> > Me.Caption = Me.Caption & ", v" & App.Major & "." & App.Minor
>> >
>> > Dim ogwApplication As GroupwareTypeLibrary.Application
>> > Dim ogwRootAccount As GroupwareTypeLibrary.Account
>> > Dim ogwFolder As Folder
>> > Dim strCommandOptions As String
>> >
>> > Dim strLoginName As String
>> > Dim strMailPassword As String
>> > Dim strFolderToSearch As String
>> > Dim strFolderToAdd As String
>> > Dim bFoundIt As Boolean
>> >
>> > strLoginName = "barkebn"
>> > strFolderToSearch = "Cabinet"
>> > strFolderToAdd = "SPAM Folder"
>> >
>> > Set ogwApplication = CreateObject("NovellGroupWareSession")
>> >
>> > ' Create connection/login to email account '
>> > If ogwRootAccount Is Nothing Or Len(strLoginName) <> 0 Then '
>> > Need to log in '
>> > ' Login to root account '
>> > If Len(strMailPassword) Then ' Password was passed, so use it
>> > '
>> > strCommandOptions = "/pwd=" & strMailPassword
>> > Else ' Password was not passed '
>> > strCommandOptions = vbNullString
>> > End If
>> >
>> > Set ogwRootAccount = ogwApplication.Login(strLoginName,
>> > strCommandOptions, , egwPromptIfNeeded)
>> > End If
>> >
>> > ' Look for the folder. If it doesn't exist, create it '
>> > bFoundIt = False
>> > For Each ogwFolder In
>> > ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders
>> > If ogwFolder.Name = strFolderToAdd Then
>> > bFoundIt = True
>> > End If
>> > Next ogwFolder
>> >
>> > If bFoundIt = False Then
>> >
>> > ogwRootAccount.AllFolders.ItemByName(strFolderToSearch).Folders.Add
>> > (strFolderToAdd)
>> > End If
>> >
>> > ' Release all objects before closing '
>> > Set ogwRootAccount = Nothing
>> > Set ogwApplication = Nothing
>> >
>> > MsgBox "Done." & vbNewLine & "To see the new folder if Groupwise is
>> > already running," & vbNewLine & "put the mouse on the Cabinet folder

>> and
>> > press F5.", vbInformation, "Folder created."
>> > End Sub
>> >
>> >
>> > What do I need to do next?

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.