IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

ENVOIE MAIL account outllook


Sujet :

Macros et VBA Excel

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Juin 2017
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2017
    Messages : 10
    Points : 6
    Points
    6
    Par défaut ENVOIE MAIL account outllook
    j'ai le code attaché qui fonctionne bien.
    seul chose je désire par défaut avoir un autre adresse mail que celle de mon account outlook

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
     
    Sub Saveaspdfandsend()
    Dim xSht As Worksheet
    Dim xFileDlg As FileDialog
    Dim xFolder As String
    Dim xYesorNo As Integer
    Dim xOutlookObj As Object
    Dim xEmailObj As Object
    Dim xUsedRng As Range
    Dim DisplayEmail As String
    Dim oAccount As Outlook.Account
    Dim oMail As Outlook.MailItem
     
     
     
     
     
     
    Set xSht = ActiveSheet
    Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
     
    If xFileDlg.Show = True Then
       xFolder = xFileDlg.SelectedItems(1)
    Else
       MsgBox "You must specify a folder to save the PDF into." & vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Must Specify Destination Folder"
       Exit Sub
    End If
    xFolder = xFolder + "\" + Cells(20, 2).Value + Cells(20, 1).Value + ".pdf"
     
    'Check if file already exist
    If Len(Dir(xFolder)) > 0 Then
        xYesorNo = MsgBox(xFolder & " already exists." & vbCrLf & vbCrLf & "Do you want to overwrite it?", _
                          vbYesNo + vbQuestion, "File Exists")
        On Error Resume Next
        If xYesorNo = vbYes Then
            Kill xFolder
        Else
            MsgBox "if you don't overwrite the existing PDF, I can't continue." _
                        & vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Exiting Macro"
            Exit Sub
        End If
        If Err.Number <> 0 Then
            MsgBox "Unable to delete existing file.  Please make sure the file is not open or write protected." _
                        & vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Unable to Delete File"
            Exit Sub
        End If
    End If
     
    Set xUsedRng = xSht.UsedRange
    If Application.WorksheetFunction.CountA(xUsedRng.Cells) <> 0 Then
        'Save as PDF file
        xSht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=xFolder, Quality:=xlQualityStandard
     
        'Create Outlook email
        Set xOutlookObj = CreateObject("Outlook.Application")
        Set xEmailObj = xOutlookObj.CreateItem(0)
     
     
     
        'pour outlook calendar
        'set xemailobj = xoutlookobj.createitem(1)
        With xEmailObj
            .Display
            .To = Cells(23, 17).Value
            .CC = ""
            .Subject = xSht.Name + ".pdf"
            .Attachments.Add xFolder
            .Body = "voici notre po"
            If DisplayEmail = False Then
     
                '.Send
     
            End If
        End With
    Else
      MsgBox "The active worksheet cannot be blank"
      Exit Sub
    End If
     
    End Sub

  2. #2
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par maxou1983 Voir le message
    Bonjour,

    Et en créant un nouveau profil dans Outlook ?

    Menu Fichier, Informations, Paramètres de compte, Gérer les profils.

Discussions similaires

  1. [AC-2013] Envoi mail automatique avec Outllook
    Par HDU71000 dans le forum VBA Access
    Réponses: 11
    Dernier message: 03/04/2018, 16h50
  2. OUTLOOK choix account pour envoi mail
    Par Arnaokee dans le forum C#
    Réponses: 0
    Dernier message: 23/07/2010, 11h00
  3. [javamail] envoi mail avec message en pièce jointe
    Par k4eve dans le forum API standards et tierces
    Réponses: 5
    Dernier message: 16/11/2007, 11h17
  4. [Envoi mails]Récupérer les enregistrements MX d'un domaine
    Par streetpc dans le forum Développement
    Réponses: 7
    Dernier message: 09/06/2004, 20h00
  5. pb envoi mail CDONTS
    Par flatron dans le forum ASP
    Réponses: 2
    Dernier message: 30/12/2003, 16h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo