Hi all
Here is my problem.
I have an agent that gathers email addresses for a mass emailing. When i send the email half the addresses get stuck and they sit in the Mail.box on the server.
When i click on the message i see that half the emails were sent ok but hal the emails are still awaiting sending and the following error appears when i try and open the message.
Illegal circular USE: coreemail classes
Below is the code i use to send the email.
FIRST SUB
Sub CreateEmails
'Set standards
Set Sess= New notessession
Set Db = Sess.CurrentDatabase
ServerName = Db.Server
’ Set Settings Doc Objects
Set SettingsView = Db.GetView( "Administration: Settings" )
Set SettingsDoc = SettingsView.GetFirstDocument
'check and make sure we can grab the mass email db that is stored in the settingsdoc
Set db2 = Sess.GetDatabase(ServerName,SettingsDoc.MassEmailDBName(0))
If db2.filename = "" Then
Call BuildErrorEmail
Exit Sub
End If
Set Notesview = db.getview("SearchMassEmailsAwaitingProcessing")
Set NotesDocColl = NotesView.GetAllDocumentsByKey("YES",True)
Set NotesDoc = NotesDocColl.GetFirstDocument
While Not NotesDoc Is Nothing
AddressArray1 = NotesDoc.EmailList1
AddressArray2 = NotesDoc.EmailList2
AddressArray3 = NotesDoc.EmailList3
AddressArray4 = NotesDoc.EmailList4
AddressArray5 = NotesDoc.EmailList5
AddressArray1 = Arrayappend( AddressArray1, AddressArray2 )
AddressArray1 = Arrayappend( AddressArray1, AddressArray3 )
AddressArray1 = Arrayappend( AddressArray1, AddressArray4 )
AddressArray1 = Arrayappend( AddressArray1, AddressArray5 )
AddressArray1 = Fulltrim(AddressArray1)
CountTo = Ubound(AddressArray1)
Count = 0
MaximumAddressesPerEmail = 100
Set EmailDoc = Nothing
'check and make sure at least 1 item is in the email list
If NotesDoc.EmailList1(0) = "" Then
NotesDoc.AwaitingProcessing = ""
Call NotesDoc.Save(True,False)
Else
CurrentAddressCount = 0
While Count <= CountTo
'IF NO EMAILDOC THEN THIS WILL BE THE FIRST STEP
If EmailDoc Is Nothing Then
Call BuildMassEmail
Call BCCItem.appendtotextlist(AddressArray1(Count))
NumberOfEmailAddresses = NumberOfEmailAddresses +1
'SEND EMAIL AS THIS IS THE LAST ADDRESS THAT CAN BE PUT ON THE EMAIL
Elseif (CurrentAddressCount + 1) = MaximumAddressesPerEmail Or Count = CountTo Then
Call BCCItem.appendtotextlist(AddressArray1(Count))
'Call EmailDoc.Save(True,False)
Call EmailDoc.Send(True)
Set EmailDoc = Nothing
NumberOfEMailsSent = NumberOfEMailsSent + 1
NumberOfEmailAddresses = NumberOfEmailAddresses +1
'IF WE GET HERE SIMPLY ADD AN ADDRESS
Else
Call BCCItem.appendtotextlist(AddressArray1(Count))
NumberOfEmailAddresses = NumberOfEmailAddresses +1
End If
CurrentAddressCount = CurrentAddressCount + 1
Count = Count + 1
Wend
End If
Set NotesDoc = NotesDocColl.GetNextDocument(NotesDoc)
Wend
If NumberOfEmailsSent > 0 Then
Call BuildAlertEmail
End If
End Sub
SECOND SUB - THIS BUILDS THE FIELD INFO FOR THE EMAIL
Sub BuildMassEmail
'THERE IS NO SEND IN THIS FUNCTION.
'THAT IS BECUASE WE CONTINUALLY ADD NAMES TO THE BCCITEM UNTIL WE REACH THE MAXIMUM (SET INITIALY TO 100)
Set EmailDoc = New NotesDocument ( db2 )
EmailDoc.Form = "Memo"
EmailDoc.Principal = ServerName
EmailDoc.Subject = NotesDoc.Subject(0)
Set BCCItem = New NotesItem( EmailDoc, "BlindCopyTo", "" )
End Sub