[besoin d'aide] Envoyer fichier Excel actif via Lotus

plc8919 - 14 déc. 2012 à 23:50
 plc8919 - 17 déc. 2012 à 12:31
Bonjour,

J'ai repris un code permettant d'envoyer un fichier excel par mail via lotus, j'aimerais votre aide pour améliorer mon code.

Voici mon code:

Option Explicit
 
Const EMBED_ATTACHMENT As Long = 1454
 
 
Const stPath As String = "c:"
 
 
 
Sub Send_Active_Sheet()
 
 
  Dim MaDate As String
 
  Dim stFileName As String
 
  Dim vaRecipients As Variant
 
  Dim vaCopyTo As Variant
 
  Dim noSession As Object
 
  Dim noDatabase As Object
 
  Dim noDocument As Object
 
  Dim noEmbedObject As Object
 
  Dim noAttachment As Object
 
  Dim stAttachment As String
 
  Dim vaMsg As String
 
  Dim stSubject As String
 
 
  MaDate = Date
 
  stSubject = "Daily event report PB PARIS" & " " & MaDate
 
  vaMsg = "Bonjour, " & vbCrLf & vbCrLf & vbCrLf & vbCrLf & _
"Veuillez trouver en pièce jointe le fichier des Pcodes sales PB PARIS du" & " " & MaDate & ":" & _
vbCrLf & vbCrLf & vbCrLf & vbCrLf & "Regards " & vbCrLf & vbCrLf & vbCrLf & _
"StSignature"
 
 
  'Copy the active sheet to a new temporarily workbook.
 
  With ActiveSheet
 
    .Copy
 
    stFileName = "Daily event report PB PARIS"
 
  End With
 
 
 
  stAttachment = stPath & "" & stFileName & ".xls"
 
 
 
  'Save and close the temporarily workbook.
 
  With ActiveWorkbook
 
    .SaveAs stAttachment
 
    .Close
 
  End With
 
 
 
  'Create the list of recipients.
 
  vaRecipients = "pierre.le.collonnier@hsbc.fr"
 
  'vaCopyTo = ""
 
 
  'Instantiate the Lotus Notes COM's Objects.
 
  Set noSession = CreateObject("Notes.NotesSession")
 
  Set noDatabase = noSession.GETDATABASE("", "")
 
 
 
  'If Lotus Notes is not open then open the mail-part of it.
 
  If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
 
 
 
  'Create the e-mail and the attachment.
 
  Set noDocument = noDatabase.CreateDocument
 
  Set noAttachment = noDocument.CreateRichTextItem("stAttachment")
 
  Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
 
 
 
  'Add values to the created e-mail main properties.
 
  With noDocument
 
    .Form = "Memo"
 
    .SendTo = vaRecipients
 
    .CopyTo = ""
 
    .Subject = stSubject
 
    .Body = vaMsg
 
    .SaveMessageOnSend = True
 
    .PostedDate = Now()
 
    .Send 0, vaRecipients
 
  End With
 
 
 
  'Delete the temporarily workbook.
 
  Kill stAttachment
 
 
 
  'Release objects from memory.
 
  Set noEmbedObject = Nothing
 
  Set noAttachment = Nothing
 
  Set noDocument = Nothing
 
  Set noDatabase = Nothing
 
  Set noSession = Nothing
 
 
 
  MsgBox "The e-mail has successfully been created and distributed", vbInformation
 
 
End Sub


Le mail envoyé grâce à cette macro est dans le PJ ci-dessous.

Mes questions sont les suivantes:

1) Peut-on modifier le code de façon a mettre la date du jour (de la variable MaDate) dans le nom du fichier envoyé en PJ ?

2) Peut-on mettre dans le code une référence à la signature de ma boîte mail de façon à ce que le message envoyé ait ma signature?

3) Peut-on envoyer le mail non pas à partir de ma boîte mail perso mais en utilisant une boîte mail générique à mon service ? Comment je pourrais réaliser cela ?

4) Peut-on modifier ce code de façon à ce qu'on me demande de vérifier le mail avant qu'il ne s'envoie ?

Bien cordialement.

1 réponse

Y aurait-il une personne assez disponible pour se pencher sur mon problème svp?
0
Rejoignez-nous