Re : créer sondage et collecter reponses mail outlook excel
Bonsoir,
Voici mon code sur lequel je bloque il envoie une demande congés a une personne (le referent) pour validation et j'ai reussi à recuperer la reponse sur excel
Dim olApp As Outlook.Application
Dim OLspace As Outlook.Namespace
Dim OLinbox As Outlook.MAPIFolder
Dim OLfolder As Outlook.MAPIFolder
Dim OLmail As Outlook.MailItem
Dim OLpj As Outlook.Attachment
Dim Msg As MailItem
Sub envoie_mail()
Set olApp = New Outlook.Application
Set Msg = olApp.CreateItem(olMailItem)
Msg.To = email
Msg.Subject = "Demande de congés"
Msg.Body = "Veuillez trouver ci joint la demande de congés du 01/01/2009 au 12/01/2009"
'Msg.Attachments.Add Source:=nom_doc
Msg.VotingOptions = "Valider;refuser"
Msg.To = Email
Msg.Display
Set olApp = Nothing
MsgBox "Message envoyé"
chMail
End Sub
Private Sub chMail()
Set olApp = CreateObject("Outlook.application")
Set OLspace = olApp.GetNamespace("MAPI")
Set OLinbox = OLspace.GetDefaultFolder(olFolderInbox)
i = 2
For Each OLmail In OLinbox.Items
If OLmail.Subject = "Valider: " Then
Dim OLbody As String
OLbody = OLmail.SenderName
olresponse = OLmail.VotingResponse
oltime = OLmail.CreationTime
olrecus = OLmail.ReceivedTime
olreceipt = OLmail.ReadReceiptRequested
Sheets(1).Range("A" & i).Select
With Selection
.Value = OLbody
End With
Sheets(1).Range("B" & i).Select
With Selection
.Value = olresponse
End With
Sheets(1).Range("C" & i).Select
With Selection
.Value = oltime
End With
Sheets(1).Range("D" & i).Select
With Selection
.Value = olrecus
End With
Sheets(1).Range("E" & i).Select
With Selection
.Value = olreceipt
End With
ElseIf OLmail.Subject = "Refuser: " Then
OLbody = OLmail.SenderName
olresponse = OLmail.VotingResponse
oltime = OLmail.CreationTime
olrecus = OLmail.ReceivedTime
Sheets(1).Range("A" & i).Select
With Selection
.Value = OLbody
End With
Sheets(1).Range("B" & i).Select
With Selection
.Value = olresponse
End With
Sheets(1).Range("C" & i).Select
With Selection
.Value = oltime
End With
Sheets(1).Range("D" & i).Select
With Selection
.Value = olrecus
End With
Sheets(1).Range("E" & i).Select
End If
Next
i = i + 1
End Sub
Ce que je souhaiterai faire c'est une fois que le mail est envoyé avec un bouton réponse au referent et qu'il valide ou refuse qu'il soit automatiquement envoyé à son supérieur et a l'agent qui avait fait la demande.
Est ce que quelqu'un peut m'aider à améliorer mon code je pensais à l'utilisation d'un evenement sur les boutons reponses mais je ne trouve pas.
merci pour votre aide bonne soirée