Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

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

    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

  3. #3
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Thanks Hans, I'll give it a whirl.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •