Je cherche à écrire un script qui, lorsqu'un technicien envoie un mail à un client, met automatiquement le commercial en lien avec ce dernier en copie.
si tech A ecrie à client A, commercial A est mis en copie pour faire simple :)
Il y a un fichier texte qui contient les correspondance afin de permettre une mise a jour plus simple (avant je me servais d'un switch dans mon code)
Dans mon projet1 je dispose de deux fichiers,
ThisOutlookSession avec le code suivant :
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'By Oliv' 29/06/2007 pour Outlook 2003 'Modifié par D. Schneider le 30/03/2015
If Not Item.Class = olMail Then GoTo fin
Dim prompt As String
'########################correspondance CC selon destinataire##############################
Dim recip As Outlook.Recipient Dim sDomain As String Dim arTemp As Variant
Sub Test_Get_Cial() Call Alimente_Liste MsgBox Get_Cial("exemple1.fr") End Sub
Sub Alimente_Liste() Dim intFic As Integer Dim strLigne As String intFic = FreeFile Open "C:\Users\YKaratekin\Dropbox\Domaine-Cial.txt" For Input As intFic i = 0 While Not EOF(intFic) Line Input #intFic, strLigne ReDim Preserve MyArray(i) MyArray(i) = strLigne i = i + 1 Wend Close intFic End Sub
Function Get_Cial(Email) As String Get_Cial = "" For i = 0 To UBound(MyArray) If Split(MyArray(i), ";", , vbTextCompare)(0) = Email Then Get_Cial = Split(MyArray(i), ";", , vbTextCompare)(1) Exit For End If Next i
End Function
C'est tout le code dont je dispose. Le fichier texte est bien à l'endroit renseigné dans mon code et ressemble à
domaine1;***@***
domaine2;***@***
Le soucis est que dès que je cherche à tester cette fonction, j'ai les soucis suivant :
http://i.imgur.com/m59ix43.png et après debogage http://i.imgur.com/zWo7rGP.png