• Sending an email with attachments via program (2002 SP3?)

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Sending an email with attachments via program (2002 SP3?)

    Author
    Topic
    #413403

    I have the need to send two files as an attachment. The following code snippet works

    stAppName = “C:Program FilesMicrosoft Office xpOffice10outlook.exe” _
    & ” /a ” & “””” & MyPath & MyCards & MyISODate & MyExt & “””” _
    & ” /c ipm.note”
    Call Shell(stAppName, 1)

    However, that only works for one file – does anyone know a way of getting two attached e.g. the following doesn’t work and I’m right out of ideas

    stAppName = “C:Program FilesMicrosoft Office xpOffice10outlook.exe” _
    & ” /a ” & “””” & MyPath & MyCards & MyISODate & MyExt & “””” _
    & ” /a ” & “””” & MyPath & MyLetters & MyISODate & MyExt & “””” _
    & ” /c ipm.note”
    Call Shell(stAppName, 1)

    Viewing 1 reply thread
    Author
    Replies
    • #911804

      Using Shell is not the ideal way to send an e-mail programmatically. If you’re doing this from within Outlook itself, you can write a macro in Outlook. If you’re doing it from another application (apparently one that has VB/VBA, you can use Automation to control Outlook: set a reference to the Microsoft Outlook 10.0 Object Library (Tools | References in the VB Editor in Office applications, Project | References in VB6).

      Dim olApp As New Outlook.Application
      Dim olMail As Outlook.MailItem

      Set olMail = olApp.CreateItem(olMailItem)
      olMail.Recipients.Add “woody@wopr.com”
      olMail.Subject = “Test mail”
      olMail.Body = “Please see the attachments.” & vbCrLf & vbCrLf & “Andrew”
      With olMail.Attachments
      .Add MyPath & MyCards & MyISODate & MyExt
      .Add MyPath & MyLetters & MyISODate & MyExt
      End With

      olMail.Send

      Set olMail = Nothing
      olApp.Quit
      Set olApp = Nothing

    • #911805

      Using Shell is not the ideal way to send an e-mail programmatically. If you’re doing this from within Outlook itself, you can write a macro in Outlook. If you’re doing it from another application (apparently one that has VB/VBA, you can use Automation to control Outlook: set a reference to the Microsoft Outlook 10.0 Object Library (Tools | References in the VB Editor in Office applications, Project | References in VB6).

      Dim olApp As New Outlook.Application
      Dim olMail As Outlook.MailItem

      Set olMail = olApp.CreateItem(olMailItem)
      olMail.Recipients.Add “woody@wopr.com”
      olMail.Subject = “Test mail”
      olMail.Body = “Please see the attachments.” & vbCrLf & vbCrLf & “Andrew”
      With olMail.Attachments
      .Add MyPath & MyCards & MyISODate & MyExt
      .Add MyPath & MyLetters & MyISODate & MyExt
      End With

      olMail.Send

      Set olMail = Nothing
      olApp.Quit
      Set olApp = Nothing

    Viewing 1 reply thread
    Reply To: Sending an email with attachments via program (2002 SP3?)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: