I wrote this code, which works fine on version 8.5 but not on version 9.0. Any suggestions?
Sub Email_Individually()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim recepient As String, Copyto As String
Dim NDoc As Object, Username As String, MaildbName As String
Dim NUIdoc As Object
Dim Maildb As Object
Dim j As Long
j = 4
While (Len(Range("d" & j).Value) > 0)
'Creates Session
Set NSession = CreateObject("Notes.NotesSession")
Set NDatabase = NSession.GETDATABASE("", "")
If NDatabase.IsOpen = True Then
Else
NDatabase.OPENMAIL
End If
'Creates New Mail
Set NDoc = NDatabase.CREATEDOCUMENT
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
recepient = Worksheets("Email info").Range("c" & j) 'Copies the email
Copyto = Worksheets("Email info").Range("d" & j) 'Copies the branch mail
With NDoc
.SendTo = recepient
.Copyto = Copyto
.Subject = "à»Ô´ÍèÒ¹ : KIKO,BullP ¨èÒ´͡àºÕé / ¤Ãº¡Ó˹´ / ¤×¹à»ç¹ËØé¹ËÃ×Íà§Ô¹ Çѹ·Õè XX ¡ØÁÀҾѹ¸ì 2561"
'Email body text
Set NotesRichTextItem = .CREATERICHTEXTITEM("Body")
NotesRichTextItem.APPENDTEXT ("äÎäÅ·ìÊÕà¢ÕÂÇ = Knock out")
NotesRichTextItem.AddNewline (2)
NotesRichTextItem.APPENDTEXT ("äÎäÅ·ìÊÕªÁ¾Ù = Knock in")
NotesRichTextItem.AddNewline (2)
NotesRichTextItem.APPENDTEXT ("µÑÇÍÑ¡ÉÃÊÕ¿éÒ = ¤Ãº¡Ó˹´ä´éà§Ô¹¤×¹")
NotesRichTextItem.AddNewline (2)
NotesRichTextItem.APPENDTEXT ("µÑÇÍÑ¡ÉÃÊÕÊéÁ = ä´éÃѺ¤×¹à»ç¹ËØé¹")
NotesRichTextItem.AddNewline (2)
.Save True, False
End With
Set NUIdoc = NUIWorkSpace.EDITDOCUMENT(True, NDoc) 'To recheck everything, before sending
With NUIdoc
'Find the marker text in the Body item
.GoToField ("Body")
Worksheets("Records").Range("a2:l2").Copy
.Paste
Worksheets("Records").Range("a" & j, "l" & j).Copy
.Paste
Worksheets("Records").Range("m2:x2").Copy
.Paste
Worksheets("Records").Range("m" & j, "x" & j).Copy
.Paste
Application.CutCopyMode = True
End With
j = j + 1
recepient = ""
Copyto = ""
Wend
Set NSession = Nothing
Set NDatabase = Nothing
Set Maildb = Nothing
Set NDoc = Nothing
Set NUIdoc = Nothing
Set NUIWorkpSpace = Nothing
End Sub