Envoyer un courriel a partir d'un user form [Fermé]

Signaler
Messages postés
122
Date d'inscription
vendredi 2 octobre 2015
Statut
Membre
Dernière intervention
3 mars 2017
-
Bonjour ,

j'essaye d'envoyer un courriel a partir d'un userform . le corps de la lettre est chargé dans un fichier word que je selectionne avant apartir du user form (Send mail).


Voici l'erreur que j'arrive pas a corriger :

The Remote service Machine does not exit on this server
   Set wdDoc = WApp.Documents.Open(wdFileName)


Voici le code du module qui assure l'envoie du courriel a travers Outlook.

Sub CommandButton2_Click()
'Déclaration des variable
'-----------------------------------------------------------------------------------------------------------------------------------------
Dim wdDoc As Object
Dim wdFileName As Variant
Dim ws As Worksheet
Dim wb As Workbook
Dim WApp As Object
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim VAR_Message As String
Dim VAR_Message_Eng As String
Dim VAR_Message_FR As String
Dim i As Integer
Dim Nbre_Line As Integer
Dim VAR_TO As String
Dim VAR_CC As String
Dim VAR_BCC As String
Dim VAR_Subject As String
Dim VAR_Beginning As String
Dim VAR_End As String
Dim ABody As String

Dim signature As String

'
'-----------------------------------------------------------------------------------------------------------------------------------------
Application.ScreenUpdating = False
wdFileName = sendmail.TextBox1.Value
' Set wb = ThisWorkbook
'Set ws = wb.Sheets("Process Info")
Set WApp = CreateObject("Word.Application")
If wdFileName = False Then Exit Sub

Set wdDoc = WApp.Documents.Open(wdFileName)

With wdDoc



'Condition pour la qualification
'-----------------------------------------------------------------------------------------------------------------------------------------
If Calendar_SLE.TextBox3.Text Like "?*@?*.?*" Then


VAR_Message_FR = "<b>" & wdDoc.Tables(1).Cell(1, 0).Range & "</b>" & "<br/>" & "<br/>" _
& "<b>" & wdDoc.Tables(1).Cell(2, 0).Range & "</b>" & "<br/>" & "<br/>" _
& "<b>" & wdDoc.Tables(1).Cell(3, 0).Range & "</b>" & "<br/>" _
& "<b>" & wdDoc.Tables(1).Cell(4, 0).Range & "</b>" & "<br/>"





VAR_Message = VAR_Message_FR


Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(olMailItem)

With OutMail
.display

End With

signature = OutMail.HTMLBody

'Setting of Email
VAR_TO = Calendar_SLE.TextBox1.Text


VAR_CC = ""
VAR_BCC = ""
VAR_Subject = ""
VAR_Beginning = ""
VAR_End = ""
ABody = VAR_Message

With OutMail
.To = VAR_TO
.CC = VAR_CC
.BCC = VAR_BCC
.Subject = VAR_Subject
.HTMLBody = ABody & signature

.display
'.Save
'.Send
End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing


Else

MsgBox ("Email non Valide")
End If

'Close the Word document with saving
wdDoc.Close False
Set wdDoc = Nothing
'wdFileName = Dir
End With
Application.ScreenUpdating = True




End Sub


Merci :)))