-
Thanks a ton to all of you.
Shrivallabha: LN reference is already made in VBA. If possible, please take a look at complete code below.
Crocus Crow: I tried your suggested code this but still facing the same problem.
Kenneth Hobs: I checked those links, not able to find code where we can move or delete inbox mails. May be I am doing something wrong here....I don't have much experience in VBA and this is the first time I am trying to connect LN with VBA.
Please see the complete code below and please advice.
*******************************************
Global Const sPathToSave As String = "C:\MailDocs\" ''''''''''path to save mail files
Global Const RICHTEXT As Long = 1
Global Const EMBED_ATTACHMENT As Long = 1454 '''''''1454 indicate a file attachment
''''''server and mail db path
Global Const sServerName = "servername"
Global Const sUserDB = "mailnsf"
Public NSession As Object 'The notes session
Public Db As Object 'The notes mail database
Public MailDoc As Object
Public Body As Object
Global sSendTo As String
Global sSubject As String
Global SAttchName As String
Global Const sBodyText As String = "Thank you for your mail."
Public Sub mail()
Dim View As Object
Dim Doc As Object
Dim NxtDoc As Object
Dim itm As Variant
Dim attch As Variant
''''''''Create Notes Session
Set NSession = CreateObject("Notes.Notessession")
''''''''Initiate Notes database and get Connection to Mail File
Set Db = NSession.GetDatabase(sServerName, sUserDB)
'''''''''Open mailbox if not already open
''''If db.IsOpen = False Then Call Db.Openmail
'''''''''Folers are viwes in LN, get Inbox view
Set View = Db.GetView("($Inbox)")
'''''Get to first mail in inbox view
Set Doc = View.GetFirstDocument
''''Iterate through all the emails in the inbox
While Not Doc Is Nothing
''''''A pointer to the next document in the view is established
Set NxtDoc = View.GetNextDocument(Doc)
''''''''Check if the current document has an attachment or not.
If Doc.HasEmbedded Then
Set itm = Doc.GetFirstItem("Body")
If itm.Type = RICHTEXT Then
''''''get all attachments
For Each attch In itm.EmbeddedObjects
If (attch.Type = EMBED_ATTACHMENT) Then
'''''get recipients mail id
sSendTo = Doc.GetItemValue("From")(0)
'''''get attachment name
SAttchName = attch.Name
'''''get subject line
sSubject = Doc.GetItemValue("Subject")(0)
'''''Save the attached file into the folder.
attch.ExtractFile sPathToSave & attch.Name
'''''Remove attachment from the mail
attch.Remove
End If
Next
Doc.Save True, False
Doc.PutInFolder "Cleared", True
''''''Delete mail document from Inbox
'Doc.Remove (True) '''-->not using since delete from both Inbox & Cleared folder
Doc.Removefromfolder "($Inbox)", True
'''''====>>>> this is where the real problem exists it never delete mail from inbox, infact make copy in Cleared Folder and create kind of link to Inbox mail and Cleared Folder mail that means if delete mail from any of these folder it get created from both..
End If
End If
''''''''calling reply mail
Set MailDoc = Db.CreateDocument
MailDoc.Form = "Memo"
MailDoc.sendto = sSendTo
MailDoc.Subject = "Re: " & sSubject & " - " & SAttchName
MailDoc.Body = sBodyText
MailDoc.SaveMessageOnSend = True
' '''''''''''Saving message
MailDoc.PostedDate = Now()
'MailDoc.Send 0, sSendTo
MailDoc.Send False
''''Refresh Inbox ===>>> i guess none of these working...i am trying to refresh mailbox by this.
Call View.Refresh
Call NSession.UpdateProcessedDoc(Doc)
''''Set current document pointer
Set Doc = NxtDoc
Wend
'''''release all memory
Set MailDoc = Nothing
Set Body = Nothing
Set NxtDoc = Nothing
Set Doc = Nothing
Set View = Nothing
Set Db = Nothing
Set NSession = Nothing
End Sub
****************************************************
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules