Saltar al contenido

Cómo adjuntar un archivo usando Thurderbird o Outlook


Recommended Posts

publicado

Ciao a
tutti e il mio problema è questo: con un foglio excel e la sua
vba vorrei inviare e-mail con
allegati pdf o altri formati che si trovano nella mia sottocartella chiamata (Utility) ma per esigenze personali uso sia (Outlook) che (Thurderbird) Ma anche se provo un mare di soluzioni, mi fa sempre dare un errore e non carico nulla si dà un'occhiata e mi dicono perché?
Grazie saluti da A.Maurizio

Prova_Email_Con_Allegato_3.rar

publicado

@A.Maurizio, para enviar por Outlook yo uso esta macro adaptada a mi necesidad. Espero te sea de ayuda.

Sub EnviarPDF()
'
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.session.logon

Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
       
With OutMail
 .To = "destinatario@hotmail.com" 'añadimos el destinatario
 .CC = "destinatario@hotmail.com" 'añadimos el correo de copia
 .BCC = ""
 .Subject = "Asunto" 'añadimos el asunto del correo
 .body = "Cuerpo del correo" 'añadimos el cuerpo y el pié.
 .Attachments.Add "C:\Users\xxxxxx\xxxxxx\archivo.pdf"  'añadimos la dirección del archivo PDF
 .send
End With

Set OutMail = Nothing: Set OutApp = Nothing
MsgBox "PROCESO FINALIZADO", vbInformation
'
End Sub

Te dejo un archivo de ejemplo.

Saludos.

Moisés.

Enviar PDF por Outlook.xlsm

publicado

Hello Pirtrafilla
Thank you so much for your help
But according to you
Where can I find concrete help on the web to help me attach a document using Thurderbird
Because actually:
Has the strength to make attempts I managed to open this application.
And it works fine too
But if I try to insert the concept of (Attachments.Add)
In this case, problems arise in the nature of sharing written data.
Therefore the program crashes and I don't understand why.
This is the part that works perfectly and Opens the application that is not (Outlook):
 

Option Explicit
Dim sdest
Dim ssubject
Dim sbody
Dim sCC
Dim sBCC

Dim RetVal As Long
Dim sCommand As String

Const SW_SHOWNORMAL As Long = &H1

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Declare Function ConnecttoprinterDig Lib "winspool.drv" (ByVal hWnd As Long, ByVal flags As Long) As Long

Private Declare Function Play Lib "WINMM.DLL" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

'Apre il Programma di Posta Elettronica Predefinita
Public Function OpenEmailProgram(ByVal EmailAndress As String) As Boolean
On Error Resume Next
Dim Res As Long
Res = ShellExecute(0&, "open", "Mailto: " & EmailAndress, vbNullString, _
vbNullString, vbNormalFocus)
OpenEmailProgram = (Res > 32)
End Function

If Not OpenEmailProgram(Sheets("Invio Email").Range("J1")) Then
MsgBox "Impossibile Eseguire il Programma di Posta Elettronica"
End If

Sub Invio_Email_thunderbird()


    Dim strCommand As String, strSubject As String, strBody As String
   
    Dim strFilePath As String

    
    strSubject = "Subject"
    strFilePath = ThisWorkbook.Path & "\Utility\1.pdf.pdf"
    strBody = "Corpo Del Messaggio 2"
    
    'use only one of the following thunderbird path, depending on your operating system:
   ' strCommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird"
   ' strCommand = "C:\Program Files (x64)\Mozilla Thunderbird\thunderbird"
    strCommand = "C:\Program Files\Mozilla Thunderbird\thunderbird"
    
    
    strCommand = strCommand & " -compose " & "to=" & Cells(1, "J") & "," & "cc=" & "," & _
    "subject=" & "Attenzione" & "," & "body=" & strBody & ", " & "attachments=" & strFilePath

    Call Shell(strCommand, vbNormalFocus)

End Sub

Now I repeat: The application that is not (Outlook) is opened
The Problem is that I do not accept The Procedure of (.Attachments.Add "C: \ Users \ xxxxxx \ xxxxxx \ archivo.pdf") As written by you in your Help.
That's all
But it does not matter ; Sooner or later I will be able to solve this problem too
Greetings and Thanks

publicado

Hi Pirtrafilla and thanks for your link, I will definitely keep it with care for the next things.
But in the meantime I managed to solve everything by myself and now it works fine.
Now for me another Problem arises which is to Create Alternative Attachments; How could they be Word / Excell / Pdf
But that I only know how to take into consideration the body of the message, including the Embedded Image; And not all of the Excel Sheet Including the Shapes.
That's all; But this is a whole other story.
Thanks anyway for your support and interest. Greetings from A.Maurizio

publicado

Hola @A.Maurizio. Prueba y si no lo consigues no dudes en preguntar, por aquí hay muchos maestros que nos ayudan mucho. Si está en mi mano hacerlo también, aunque yo soy mas novato.

También en internet hay bastante información sobre añadir archivos o similar, por Outlook, Hotmail, Gmail...

Moisés.

 

 

publicado

Hola Pirtrafilla Gracias por el Concejo lo haré de inmediato, no solo porque sé que este foro está todo preparado y gente amigable; Pero también porque llevo un tiempo intentándolo sin conseguir nada.
Gracias infinito
Hola y que tengas un buen fin de semana

##########################################################

Hello Pirtrafilla Thanks for the Council I will do it immediately, not only because I know that this forum is all prepared and friendly people; But also because I've been trying for a while without getting anything
Thanks Infinite
Hello and have a good weekend

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.