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:
But: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 = "mail@mail.com"
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
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!
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?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks