+ Reply to Thread
Results 1 to 2 of 2

VBA and Groupwise

  1. #1
    Registered User
    Join Date
    04-02-2009
    Location
    Vienna
    MS-Off Ver
    Excel 2003
    Posts
    2

    VBA and Groupwise

    Hi Guys - my first entry here...

    I am trying make an automaticly generated groupwise mail with excel 2003 using vba. so far, i have discovered following code, which is actually working perfect:

    Sub Groupwise_Mail()

    Dim objGroupWise As Object
    Dim objAccount As Object
    Dim objMessages As Object
    Dim objMessage As Object
    Dim objMailBox As Object
    Dim objRecipients As Object
    Dim objRecipient As Object
    Dim objAttachment As Object
    Dim objAttachments As Object
    Dim objMessageSent As Variant

    Dim Subject As String, Attachment As String, Recipient As String, Bodytext As String

    On Error Goto Errorhandling

    'Här skapas e-postinnehållet.

    Subject = "Test"

    'Attachment = ThisWorkbook.Path & "\Test.xls"

    Recipient = "[email protected]"

    Bodytext = "Enligt överenskommelse"

    'Här ansluter vi till GroupWise och skapar själva e-postet.

    Set objGroupWise = CreateObject("NovellGroupWareSession")
    Set objAccount = objGroupWise.Login
    Set objMailBox = objAccount.MailBox
    Set objMessages = objMailBox.Messages
    Set objMessage = objMessages.Add("GW.MESSAGE.MAIL", "Draft")
    Set objRecipients = objMessage.Recipients
    Set objRecipient = objRecipients.Add(Recipient)
    Set objAttachments = objMessage.Attachments
    Set objAttachment = objAttachments.Add(Attachment)

    With objMessage
    .Subject = Subject
    .Bodytext = Bodytext
    End With

    Set objMessageSent = objMessage.Send

    ExitHere:

    Set objGroupWise = Nothing
    Set objAccount = Nothing
    Set objMailBox = Nothing
    Set objMessages = Nothing
    Set objMessage = Nothing
    Set objRecipients = Nothing
    Set objAttachments = Nothing
    Set objRecipient = Nothing
    Set objAttachment = Nothing
    Exit Sub

    Errorhandling:

    MsgBox Err.Description & " " & Err.Number

    Resume ExitHere

    End Sub
    But:

    1) I would like to address Recipients in CC as well. Line Set objRecipient = objRecipients.Add(Recipient) adds new recipients, but how do i put them in 'CC'?

    2) I would like to add an attachment to the mail. This is why i have modified the line Attachment = "G:\XY\ALLE\Handblatt-Indikatoren\Kurzfristige_Indikatoren.xls and "Set objAttachment = Nothing" . In spite of this, the email is sent, but attachment is still missing. What did i forget?

    Thanks for any advice!

  2. #2
    Registered User
    Join Date
    02-27-2004
    Location
    Australia
    Posts
    16

    Exclamation Re: VBA and Groupwise

    I added the line
    .Attachments.Add "D:\CSR\HEEMAN.txt" after
    .Bodytext = Bodytext to the same codes for attachments but I got the follwing error:
    [An invalid argument was passed in the function call. -2147352567]. The object library "GroupwareTypeLibrary" was checked. Does anyone know what that error mean?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1