Automation error

J

Jørgen

I'm trying to send an email from a .dll.
The problem is that when run within VB6 it works, but when compiled and put
on the server it fails in line: 017 stating that this is not allowed.
Please help....

001 Function sendContract(ByVal ContractNo As Long, _
002 ByVal mailTO As String, _
003 ByVal mailATTACH As String)
004
005 Dim objOutlook As Outlook.Application
006 Dim objOutlookMsg As Outlook.MailItem
007 Dim objOutlookRecip As Outlook.Recipient
008 Dim objOutlookAttach As Outlook.Attachments
009
010 Set objOutlook = CreateObject("Outlook.Application")
011 Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
012 Set objOutlookRecip = objOutlookMsg.Recipients.Add(mailTO)
013 objOutlookRecip.Type = olTo
014 objOutlookMsg.Subject = "Contrakt nr.:" & CStr(ContractNo)
015 objOutlookMsg.Importance = olImportanceHigh
016 objOutlookMsg.Save
017 Set objOutlookAttach = objOutlookMsg.Attachments
018 objOutlookAttach.Add mailATTACH, olByValue, 1, "Contrakt"
019 objOutlookMsg.Send
020
021 End Function
 
D

Dmitry Streblechenko \(MVP\)

Try to add a couple more lines after the following line:
Set objOutlook = CreateObject("Outlook.Application")

set NS = objOutlook.GetNamespace("MAPI")
NS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top