>Hi,
>
>This is a routine I have is stored the Init event of a form. I have the Microsoft MAPI Session and Message Control dropped on my form. I named the Session object OLESessionMAPI and the Message object OLEMessageMAPI.
>
>The following routine is supposed to attach a file named "Ca000001.txt" located in the "C:\Email" directory, and send it out to an internet recipient, "
vlahosj@total.net".
>
>Can anyone tell me why this code is failing at run time at the
>".Send()" event? Has anyone else had problems getting the MAPI Activex to work?
>
>The error message I get is "OLE error code 0x80020010:Invalid callee.".
>
>I've tried this on several workstations, all with internet connections using MS-Exchange with the proper 32-bit MAPI DLLs installed.
>
>NOTE: The user name and password are not the reall ones.
>
>>
>
>ThisForm.OLESessionMAPI
> .LogonUI=.F.
> .NewSession=.F.
> .Username="TestUsername"
> .Password="TestPassword"
>
> .SignOn()
>ENDWITH
>
>WITH ThisForm.OLEMessageMAPI
> .SessionID = ThisForm.OLESessionMAPI.SessionID
> .Compose()
>
> .MsgType = ""
> .MsgSubject = "CAMPAIGN FILES"
> .MsgNoteText = "Here it is..."
>
> .AttachmentIndex = .AttachmentCount + 1
> .AttachmentName = "Ca000001.txt"
> .AttachmentPathName = "C:\Email\Ca000001.txt"
> .AttachmentPosition = 12
> .AttachmentType = 0
>
> .RecipIndex = .RecipCount + 1
> .RecipAddress = "
vlahosj@total.net"
> .RecipDisplayName = "John Vlahos"
> .RecipType=1
>
> .Send()
>ENDWITH
>
>ThisForm.OLESessionMAPI.SignOff
>ThisForm.Release()
>
><
>
>Thank you,
>John Vlahos
Following sample works Ok:
if type('oSession')<>"O"
oSession=createobject("MAPI.Session")
oSession.Logon("MS Exchange Settings",.f.)
endif
oMessage=oSession.OutBox.Messages.Add()
oMessage.Subject="Email Test"
oMessage.Text="Skol'ko mozhno zhdat'"
oAttach=oMessage.Attachments.Add()
With oAttach
.type=1
.name="c:\temp\text1.txt"
.readfromfile("c:\temp\text1.txt")
endwith
oAttach.name="text1.txt"
oRecipient=oMessage.Recipients.Add()
with oRecipient
.Name="ed pikman"
.Address="SMTP:epikman@usa.net"
.AddressEntry.Type="SMTP"
.AddressEntry.Address="epikman@usa.net"
endwith
oMessage.Update()
oMessage.Send(.t.,.f.)
Edward Pikman
Independent Consultant