forward automatique de mail en VBA

alibebette

XLDnaute Nouveau
bonjour,

j'aimerais créer une macro en VBA sous excel qui puisse transférer tous mes mails sous "Lotus Notes" vers une adresse bien précise.

j'ai identifier une macro qui crée de nouveaux mails (voir ci apres) mais ce n'est pas ce que je souhaite faire puisque mon besoin est de reprendre les mail de mon "in box" et de les envoyer vers une autre adresse.

Pour ceci je me demandais si au lieu de l'instruction
"Set mailDoc = mailDb.CREATEDOCUMENT"
s'il n'existe pas quelque chose du genre
"Set mailDoc = mailDb.forward.currentmail" et une instruction permettant de balayer tous les mails de mon inbox.

Merci pour vos réponses.

Sub SendNotesMail()
'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")
'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
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 = "XXL@gmail.com"
mailDoc.Subject = Worksheets(3).Cells(1, 2).Value
mailDoc.body = Worksheets(3).Cells(3, 2).Value
mailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
Attachment1 = Worksheets(3).Cells(4, 2).Value
Attachment2 = Worksheets(3).Cells(5, 2).Value
Attachment3 = Worksheets(3).Cells(6, 2).Value
If Attachment1 <> "" And Attachment2 <> "" And Attachment3 <> "" Then
Set AttachME = mailDoc.CREATERICHTEXTITEM("Attachment1")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment1, "Attachment1")
mailDoc.CREATERICHTEXTITEM (Attachment1)
Set AttachME = mailDoc.CREATERICHTEXTITEM("Attachment2")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment2, "Attachment2")
mailDoc.CREATERICHTEXTITEM (Attachment2)
Set AttachME = mailDoc.CREATERICHTEXTITEM("Attachment3")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment3, "Attachment3")
mailDoc.CREATERICHTEXTITEM (Attachment3)
End If

'Send the document
mailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
mailDoc.SEND 0, Recipient

'Clean Up
Set mailDb = Nothing
Set mailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing

End Sub
 

Discussions similaires

Réponses
6
Affichages
311
Réponses
17
Affichages
1 K

Statistiques des forums

Discussions
312 358
Messages
2 087 584
Membres
103 600
dernier inscrit
Tora61