Consulting

Results 1 to 7 of 7

Thread: Solved: Excel VBA Email to more than one recipient

  1. #1

    Solved: Excel VBA Email to more than one recipient

    Hi Guys!

    In the code below everythings functions, except if i want to put mor than one recipient (with the array type). I'm sure its only a small thing....

    Anyone knows what's wrong?



    Sub Button2_Click()
    Dim message As Object, OutApp As Object
    Set OutApp = CreateObject("Outlook.Application")
    Dim AWS As String
    'active sheet gets sent by email
    AWS = ThisWorkbook.FullName
    Set message= OutApp.CreateItem(0)
    With message
    .to = Array("xxx@xxx.com", "yyy@yyy.com")

    .Subject = "A new engagement is ready for processing! " & Date & Time
    .attachments.Add AWS
    .Body = "Hi SWISSO. Please process this engagement."
    'mail gets displayed
    .Display
    'mail goes into sent items
    'Mail.Send
    End With
    'Outlook schliessen
    OutApp.Quit
    Set OutApp = Nothing
    Set Nachricht = Nothing
    End Sub

    thanks to you.

    Greetz

    Ben

  2. #2
    VBAX Tutor CCkfm2000's Avatar
    Joined
    May 2005
    Posts
    209
    Location
    try

    [vba] Sub Button2_Click()
    Dim message As Object, OutApp As Object
    Set OutApp = CreateObject("Outlook.Application")
    Dim AWS As String
    'active sheet gets sent by email
    AWS = ThisWorkbook.FullName
    Set message= OutApp.CreateItem(0)
    With message
    .to = Array("xxx@xxx.com; yyy@yyy.com")

    .Subject = "A new engagement is ready for processing! " & Date & Time
    .attachments.Add AWS
    .Body = "Hi SWISSO. Please process this engagement."
    'mail gets displayed
    .Display
    'mail goes into sent items
    'Mail.Send
    End With
    'Outlook schliessen
    OutApp.Quit
    Set OutApp = Nothing
    Set Nachricht = Nothing
    End Sub[/vba]

  3. #3
    hi CCkfm2000

    that doesn't seem to work....:-(


    it says that "outlook cannot translate your string"....

  4. #4
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Try this one :
    [VBA]Sub Button2_Click()
    Dim message As Object, OutApp As Object, wb As Workbook
    Set OutApp = CreateObject("Outlook.Application")
    Set wb = ActiveWorkbook
    Set message = OutApp.CreateItem(0)
    With message
    'Could be that you have to alter ; to ,
    .to = "xxx@xxx.com; yyy@yyy.com"
    .Subject = "A new engagement is ready for processing! / " & _
    Date & " - " & Time
    .attachments.Add wb.FullName
    .Body = "Hi SWISSO. Please process this engagement."
    'mail gets displayed
    .Display
    'mail goes into sent items
    'Mail.Send
    End With
    'Outlook schliessen
    'OutApp.Quit
    Set OutApp = Nothing
    'Set Nachricht = Nothing
    End Sub[/VBA]Charlize

  5. #5
    worked now

    sometimes, it's the little things :-)


    thanks!


    greetz

    ben

  6. #6
    guys, i have another prob.

    if the file gets filled out in excel and sent with the button with the code like above, the receiver only sees the file, but not with the values a user has put in. in other words: it looks like you have to save your entries, saving the file and the send it and then it's ok.

    but is there a way that you dont need to save this, sending a excel form with entered data without the forcing to save?

  7. #7
    anyone?

Posting Permissions

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