Attach File on OUTLOOK 2002 
Author Message
 Attach File on OUTLOOK 2002

Dear all
     I don't know what happen on my program. The program can work on Outlook
Express, but doesn't work on OULOOK 2002.
The Porgram Code is :
      oSession = CREATEOBJECT("MSMapi.MapiSession")
      oMessage = CREATEOBJECT("MSMapi.MapiMessages")

      oSession.LogonUI = .t.
      oSession.SignOn

      *-- The message control needs to reference the session control's ID.
      oMessage.SessionID = oSession.SessionID
      oMessage.MsgIndex = -1

      *-- Set up our message and send it.
      oMessage.Compose
      oMessage.msgsubject = "Customer DataBase"

      *-- Create an array holding the attachment file names.
      DIMENSION lcAttachment(1)
      lcAttachment(1) = home()+ "customer.dbf"

      *-- Attach the files.
      FOR lnCount = 1 TO ALEN(lcAttachment)
         oMessage.AttachmentIndex = lnCount - 1
         oMessage.AttachmentPathName = lcAttachment(lnCount)
      ENDFOR

      *-- Send the message on its way.
      oMessage.send(1)



Sun, 04 Sep 2005 14:15:16 GMT  
 Attach File on OUTLOOK 2002
Hello, JJ!
You wrote  on Wed, 19 Mar 2003 14:15:16 +0800:

 J>       oSession.LogonUI = .t.
 J>       oSession.SignOn

 J>       *-- The message control needs to reference the session control's
 J> ID.
 J>       oMessage.SessionID = oSession.SessionID
 J>       oMessage.MsgIndex = -1

 J>       *-- Set up our message and send it.
 J>       oMessage.Compose
 J>       oMessage.msgsubject = "Customer DataBase"

 J>       *-- Create an array holding the attachment file names.
 J>       DIMENSION lcAttachment(1)
 J>       lcAttachment(1) = home()+ "customer.dbf"

 J>       *-- Attach the files.
 J>       FOR lnCount = 1 TO ALEN(lcAttachment)
 J>          oMessage.AttachmentIndex = lnCount - 1
 J>          oMessage.AttachmentPathName = lcAttachment(lnCount)
 J>       ENDFOR

 J>       *-- Send the message on its way.
 J>       oMessage.send(1)

Do you get some kind of error?
---
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 15:53:53 GMT  
 Attach File on OUTLOOK 2002
Hello, Eric!
You wrote to JJ on Wed, 19 Mar 2003 08:53:53 +0100:

 EdD> Do you get some kind of error?

Mmm I'm getting a "Unspecified Failure" error message. Not sure why this is.
Perhaps an alternative would be to use ole automation if the default mail
client is Outlook. Use MAPI for other mail clients. Sample code:

* send mail using OLE automation
loOutlook = CREATEOBJECT("Outlook.Application")
loMailItem = loOutlook.createitem(0)
loMailItem.Subject = "your subject"
loMailItem.Attachments.add("c:\yourfile.doc")
loMailItem.body = "your message body"
loMailItem.display

* function to get path to default mail client program:
FUNCTION GetDefaultMailClient
 #DEFINE SECURITY_ACCESS_MASK 983103
 #DEFINE HKEY_CLASSES_ROOT 0x80000000
 DECLARE INTEGER RegOpenKeyEx IN Win32API ;


 DECLARE INTEGER RegQueryValueEx IN Win32API ;
 INTEGER nKey, STRING cValueName, INTEGER nReserved,;

 DECLARE INTEGER RegCloseKey IN Win32API ;
 INTEGER nKey
 LOCAL lnHandle, lcSubKey, lcBuffer, lcRetval
 lcSubKey = "mailto\shell\open\command"
 lnHandle = 0
 lcBuffer = SPACE(255) + CHR(0)


 RegCloseKey(lnHandle)
RETURN lcBuffer
ENDFUNC

Hope this helps.
---
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 17:12:13 GMT  
 Attach File on OUTLOOK 2002

Hello !
    I got the error message is :  OLE IDispatch exception code 0 from MAPIMessages: Unspecified Failure has occurred.


Quote:
> Hello, JJ!
> You wrote  on Wed, 19 Mar 2003 14:15:16 +0800:

>  J>       oSession.LogonUI = .t.
>  J>       oSession.SignOn

>  J>       *-- The message control needs to reference the session control's
>  J> ID.
>  J>       oMessage.SessionID = oSession.SessionID
>  J>       oMessage.MsgIndex = -1

>  J>       *-- Set up our message and send it.
>  J>       oMessage.Compose
>  J>       oMessage.msgsubject = "Customer DataBase"

>  J>       *-- Create an array holding the attachment file names.
>  J>       DIMENSION lcAttachment(1)
>  J>       lcAttachment(1) = home()+ "customer.dbf"

>  J>       *-- Attach the files.
>  J>       FOR lnCount = 1 TO ALEN(lcAttachment)
>  J>          oMessage.AttachmentIndex = lnCount - 1
>  J>          oMessage.AttachmentPathName = lcAttachment(lnCount)
>  J>       ENDFOR

>  J>       *-- Send the message on its way.
>  J>       oMessage.send(1)

> Do you get some kind of error?
> ---
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 17:17:53 GMT  
 Attach File on OUTLOOK 2002
Worked for me IF I removed the attachment stuff and added



after the "compose"

(Note that the Display Name is the e-mail address -- Exchange bounced the
messages unless I did it this way).

An alternative that seems to work is ShellExecute. This code comes from an
old newsgroup message:

DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, STRING cAction, STRING cFileName, ;
STRING cParams, STRING cDir, INTEGER nShowWin



"&Body= Test body."
ShellExecute(0,"open",lcMail,"","",1)

-Cliff



Quote:
> Hello, Eric!
> You wrote to JJ on Wed, 19 Mar 2003 08:53:53 +0100:

>  EdD> Do you get some kind of error?

> Mmm I'm getting a "Unspecified Failure" error message. Not sure why this
is.
> Perhaps an alternative would be to use ole automation if the default mail
> client is Outlook. Use MAPI for other mail clients. Sample code:

> * send mail using OLE automation
> loOutlook = CREATEOBJECT("Outlook.Application")
> loMailItem = loOutlook.createitem(0)
> loMailItem.Subject = "your subject"
> loMailItem.Attachments.add("c:\yourfile.doc")
> loMailItem.body = "your message body"
> loMailItem.display

> * function to get path to default mail client program:
> FUNCTION GetDefaultMailClient
>  #DEFINE SECURITY_ACCESS_MASK 983103
>  #DEFINE HKEY_CLASSES_ROOT 0x80000000
>  DECLARE INTEGER RegOpenKeyEx IN Win32API ;


>  DECLARE INTEGER RegQueryValueEx IN Win32API ;
>  INTEGER nKey, STRING cValueName, INTEGER nReserved,;

>  DECLARE INTEGER RegCloseKey IN Win32API ;
>  INTEGER nKey
>  LOCAL lnHandle, lcSubKey, lcBuffer, lcRetval
>  lcSubKey = "mailto\shell\open\command"
>  lnHandle = 0
>  lcBuffer = SPACE(255) + CHR(0)



>  RegCloseKey(lnHandle)
> RETURN lcBuffer
> ENDFUNC

> Hope this helps.
> ---
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 23:03:11 GMT  
 Attach File on OUTLOOK 2002
Hello, Newspost!
You wrote  on Wed, 19 Mar 2003 17:03:11 +0200:

 N> An alternative that seems to work is ShellExecute. This code comes from

Just one note about using ShellExecute and mailto: attachments are not
supported.
---
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Sun, 04 Sep 2005 23:11:15 GMT  
 Attach File on OUTLOOK 2002
Thank you....



Quote:
> Hello, Eric!
> You wrote to JJ on Wed, 19 Mar 2003 08:53:53 +0100:

>  EdD> Do you get some kind of error?

> Mmm I'm getting a "Unspecified Failure" error message. Not sure why this
is.
> Perhaps an alternative would be to use ole automation if the default mail
> client is Outlook. Use MAPI for other mail clients. Sample code:

> * send mail using OLE automation
> loOutlook = CREATEOBJECT("Outlook.Application")
> loMailItem = loOutlook.createitem(0)
> loMailItem.Subject = "your subject"
> loMailItem.Attachments.add("c:\yourfile.doc")
> loMailItem.body = "your message body"
> loMailItem.display

> * function to get path to default mail client program:
> FUNCTION GetDefaultMailClient
>  #DEFINE SECURITY_ACCESS_MASK 983103
>  #DEFINE HKEY_CLASSES_ROOT 0x80000000
>  DECLARE INTEGER RegOpenKeyEx IN Win32API ;


>  DECLARE INTEGER RegQueryValueEx IN Win32API ;
>  INTEGER nKey, STRING cValueName, INTEGER nReserved,;

>  DECLARE INTEGER RegCloseKey IN Win32API ;
>  INTEGER nKey
>  LOCAL lnHandle, lcSubKey, lcBuffer, lcRetval
>  lcSubKey = "mailto\shell\open\command"
>  lnHandle = 0
>  lcBuffer = SPACE(255) + CHR(0)



>  RegCloseKey(lnHandle)
> RETURN lcBuffer
> ENDFUNC

> Hope this helps.
> ---
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Mon, 05 Sep 2005 10:22:56 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Attach file from OUTLOOK

2. Attach file to Outlook

3. Word 2002 Error Message: Unable to Open Data Source using Visual FoxPro Data Base File

4. Accessing FoxPro tables with Access 2002

5. How To Connect Visual FoxPro 7 Data Source to Word 2002 (or Office XP Applications)

6. Word Automation and Norton's Antivirus 2002

7. VIM 2002.02.180 -- Asynchronous (Event) Network processing added

8. Jan 2002 MSDN - where is the VFP help?

9. VFUG Instant Messenger (VIM) v.2002.02.110 Now Online

10. Word automation in Windows XP/Word 2002

11. Can I attach icon in Foxpro .exe file

12. Foxpro 2.5 Attaching files to records?

 

 
Powered by phpBB® Forum Software