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
Bookmarks