Runtime error 7078

G

Guest

I was using the following code to send an email by Lotus from Access. It used
to work very great. but suddenly an runtime error 7078 - could not create
field %1 occurs and the code stop at Maildoc.copyto = cc_name

i don't know why. could anyone pleae help?

the code was copied from the following link.
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

Private Sub but_send_Click()
Dim subject1, attachment1, recipient1, CC_Name1(1 To 10), Body As String
subject1 = "Text"
attachment1 = "File Name"
recipient1 = DLookup("[E-mail]", "Tb_Contact_Person", "[Contact
Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(1) = DLookup("[bank_cc]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(2) = DLookup("[bank_cc1]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(3) = DLookup("[bank_cc2]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(4) = DLookup("[bank_cc3]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
If Forms!Control![combohandled by] = DLookup("[Full_Name]",
"Tb_Login", "[login] = '" & Forms!switchboard.txtname & "'") Then
CC_Name1(5) = DLookup("[E-mail]", "Handled", "[Handled By] =
'" & Forms!Control.[combohandled by] & "'")
Else
CC_Name1(5) = DLookup("[E-mail]", "Handled", "[Handled By] =
'" & Forms!Control.[combohandled by] & "'")
CC_Name1(6) = DLookup("[E-mail]", "Tb_Login", "[Login] = '"
& Forms!switchboard.tXtname & "'")
End if
Body = "Text"
Email subject1, attachment1, recipient1, CC_Name1, Body, True
End Sub

Function Email(Subject, Attachment, Recipient, CC_Name, BodyText, SaveIt As
Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document

Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.Sendto = Recipient
MailDoc.copyto = CC_Name
 
J

James A. Fortune

B said:
I was using the following code to send an email by Lotus from Access. It used
to work very great. but suddenly an runtime error 7078 - could not create
field %1 occurs and the code stop at Maildoc.copyto = cc_name

i don't know why. could anyone pleae help?

the code was copied from the following link.
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

Private Sub but_send_Click()
Dim subject1, attachment1, recipient1, CC_Name1(1 To 10), Body As String
subject1 = "Text"
attachment1 = "File Name"
recipient1 = DLookup("[E-mail]", "Tb_Contact_Person", "[Contact
Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(1) = DLookup("[bank_cc]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(2) = DLookup("[bank_cc1]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(3) = DLookup("[bank_cc2]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
CC_Name1(4) = DLookup("[bank_cc3]", "Tb_Contact_Person",
"[Contact Person] = '" & Forms!Control.[Contact Person] & "'")
If Forms!Control![combohandled by] = DLookup("[Full_Name]",
"Tb_Login", "[login] = '" & Forms!switchboard.txtname & "'") Then
CC_Name1(5) = DLookup("[E-mail]", "Handled", "[Handled By] =
'" & Forms!Control.[combohandled by] & "'")
Else
CC_Name1(5) = DLookup("[E-mail]", "Handled", "[Handled By] =
'" & Forms!Control.[combohandled by] & "'")
CC_Name1(6) = DLookup("[E-mail]", "Tb_Login", "[Login] = '"
& Forms!switchboard.tXtname & "'")
End if
Body = "Text"
Email subject1, attachment1, recipient1, CC_Name1, Body, True
End Sub

Function Email(Subject, Attachment, Recipient, CC_Name, BodyText, SaveIt As
Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) -
InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document

Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
MailDoc.Sendto = Recipient
MailDoc.copyto = CC_Name

I'm only guessing, but try MailDoc.copyto = Nz(CC_Name,"") instead of
MailDoc.copyto = CC_Name.

Most of the variables that you think are Dim'ing as String are actually
being Dim'ed as Variant. These variant fields allow the possibility of
getting Null values. That's one of the reasons why I usually put each
Dim statement on a separate line.

James A. Fortune
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top