envoyer un mail avec outlook

envoyer un mail avec outlook - VB/VBA/VBS - Programmation

Marsh Posté le 12-06-2002 à 17:00:13    

Ici le but est d'envoyer simplement un mail avec outlook grace a vb j'ai un code qui devrait fonctionner mais n'envoi rien réellement
voici le code :
 
Private Sub Command1_Click()
' Start Outlook.
' If it is already running, you'll use the same instance...
   Dim olApp As Outlook.Application
   Set olApp = CreateObject("Outlook.Application" )
     
' Send a message to your new contact.
   Dim olMail As Outlook.MailItem
   Set olMail = olApp.CreateItem(olMailItem)
' Fill out & send message...
   olMail.ReplyRecipients = "kim@kim.com"
   olMail.To = "milkyway11@caramail.com"
   olMail.Subject = "About our meeting..."
   olMail.Body = " salut what's up ?"
   olMail.Send
     
 ' Clean up...
   MsgBox "All done...", vbMsgBoxSetForeground
   olNs.Logoff
   Set olNs = Nothing
   Set olMail = Nothing
   'Set olAppt = Nothing
   'Set olItem = Nothing
   Set olApp = Nothing
 
 
End Sub

Reply

Marsh Posté le 12-06-2002 à 17:00:13   

Reply

Marsh Posté le 12-06-2002 à 17:01:29    

si qq a une idée :bounce:  
ca serait bien urbain...

Reply

Marsh Posté le 12-06-2002 à 17:05:51    

En fait il y a une ligne foireuse que je n'ai pas mise en commentaire c'est :
 
 olMail.ReplyRecipients = "kim@kim.com"
 
voilà si qq a une chtite idée.....

Reply

Marsh Posté le 13-06-2002 à 10:53:24    

Ben moi avec ce code ca marche :
 
Dim olapp As Object
  On Error Resume Next
    Set olapp = GetObject(, "Outlook.Application" )
  If Err.Number Then
    Err.Clear
    Set olapp = CreateObject("Outlook.Application" )
    If Err.Number Then
      MsgBox "Can't open Outlook."
   End If
  End If
  Set olMail = olapp.CreateItem(olMailItem)
  olMail.To = "mail@mail.es"
  olMail.Subject = ""
  olMail.Body = " "
  olMail.Display True ' ou olMail.Send
   
  MsgBox "Email enviado", vbMsgBoxSetForeground
   
   Set olMail = Nothing
  Set olapp = Nothing


Message édité par Turk182 le 13-06-2002 à 12:29:11

---------------
Mes mémoires de Retrogamer - Le Retroblog de Turk182! en livres - Suivez le blog sur Facebook
Reply

Marsh Posté le 14-06-2002 à 12:01:19    

oki merci... en fait moi ca merdait parce que mes comptes étaient configurés seulement dans Outlook express et pas dans Outlook tout court  :pt1cable:  
par contre g un autre petit souci je veux faire une boucle pour envoyer plusieurs emails à la fois mais Outlook-XP flippe que ca soit un virus et demande une confirmation à chaque mail emis je sais pas comment virer ca...
si qq sait comment faire ca serait sympa
 :hello:

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed