Hi Thomas

I got this of the list some time ago. It's not mine and I haven�t tried it
out and it's includes VB6 too, but give it a go if You can..... (Original
Source from John Brosowsky)


'********************

Saw some discussion about trying to email attachments from MB recently.
 
I use mapbasic and Visual Basic rather then file->send mail for more
control, like attachments, etc. To cause mapbasic programs to launch my
e-mail software with a map or other file attached I just first create the
file in mapbasic, then have the mb app run a simple Visual Basic 6.0 app to
launch the default mapi e-mail software with a new e-mail and attachment. 

To avoid having to use DDE I just have the MB app dump info about what file
to attach to a little text file. The VB program reads the file, and launches
the default mapi e-mail with a new message and attachment.

Its really easy to do in VB.   Just create a new project with a single form.
Add "MicroSoft MAPI Controls 6.0" from project -> components. Then in the VB
form add the MAPIMessages control and the MAPISession control. Then just add
the following code to the program and your set:

Private Sub Form_Load()
    '*** get the file to email from the mapbasic program    
    Dim fileName As String
    Open App.Path & "\file.ini" For Input As #1
    Input #1, fileName    
    Close #1
    '**** launch email and attach file
    MAPISession1.SignOn
    MAPIMessages1.SessionID = MAPISession1.SessionID
    MAPIMessages1.Compose
    MAPIMessages1.AttachmentPathName = fileName
    MAPIMessages1.AttachmentIndex = 0
    MAPIMessages1.AttachmentPosition = 0
    MAPIMessages1.Send True
    MAPISession1.SignOff
    '**** all done, quit this puppy - happens so fast you'll never see this
form on the screen
    Unload Me
End Sub

To run the VB application from mapbasic, just complile it to an exe file and
use a line in your mapbasic program like: Run Program "c:\runMAPI.exe"

Of course you need VB to do the above yourself, but I have just compiled the
little app and created a setup program so you can install runMAPI on any PC
with or without VB. I also have a sample MB program that demonstrates using
it to add an e-mail option to the main mapinfo menu bar.

'*********************

Regards

Thomas Brix Lyng
Frederikshavn Munincipal Administration
Denmark
+045 96 22 53 21


-----Oprindelig meddelelse-----
Fra: Thomas Rokkj�r [mailto:throk@;orange.dk]
Sendt: 12. november 2002 13:06
Til: '[EMAIL PROTECTED]'
Emne: MI-L Sending mail through MapInfo


I would like to know, if anyone knows of a way to send mails through MapInfo
Professional. I need to automatically specify the recipient and subject. I
know of the M_SENDMAIL_CURRENTWINDOW and M_SENDMAIL_WORKSPACE definitions,
but these cannot be used for specifying the recipient and subject, the way I
see it. I believe the solution is to use the Run Program statement, where
the program_spec should be the mail client and then some specific
command-line arguments.

Med venlig hilsen / Best regards 
-- 
Thomas Rokkj�r, GIS Developer, Orange A/S 
Prags Boulevard 80, DK-2300 K�benhavn S 
+45 26800766. 

 

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 4037

Reply via email to