Excel vers Outlook

J'aimerais avoir un bouton dans une feuille excel qui me permette d'envoyer automatiquement un mail via outlook.

Voici un exemple de code que tu peux associer à ton bouton... Attention, il requiert la reference à Microsoft Outlook 8.0 Object Library

sub Outlook()
 Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem, ToContact As
 Recipient
 MESsages = MSG11 & MSG12 & MSG13 & MSG14
  Set OLF = GetObject("",
 "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
  Set olMailItem = OLF.Items.Add
  With olMailItem
    .subject = "XXXXXXXXXXXX"
    Set ToContact = .Recipients.Add("XXXXX@XXXXXX.XXX)
    .Body = "ton message"
    .Attachments.Add "C:\PDM" & SOCiete & "" & Nomvar,
 olByValue, ,
 "le fichier que tu veux joindre"
    .OriginatorDeliveryReportRequested = False
    .ReadReceiptRequested = False
    .Send
  End With
  Set ToContact = Nothing
  Set olMailItem = Nothing
  Set OLF = Nothing
 end sub

Astuce illustrée par ce classeur
jb-envoipagemail

Auteur :

Mot clef associé à cette page :