Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > Code & Utilities

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 10th July 2002, 11:03
carice's Avatar
carice carice is offline
Member
 
Join Date: Mar 2002
Location: Belgium
Posts: 38
carice is on a distinguished road
Baan: BaanIV; BaanV (5.0;5.1;5.2) - DB: BISAM; ORACLE - OS: WINNT; UNIX
Post How to use MS OUTLOOK

In baan you create a session with a few formfields (you can start with from; to ; subject and body).
In a later stadium you can use more fields like cc, attachment, ...
Code:
|******************************************************************************
|* Send Outlook Mail
|* filip demeulemeester
|* 06-03-02 [09:13]
|*
|* Copyright 2002 by Demeulemeester Filip
|* You can contact me at <a href="mailto:flaip@hotmail.com">flaip@hotmail.com</a>
|* All Rights Reserved 
|*
|* Permission to use, copy, modify, and distribute this software and its documentation for any purpose 
|* and without fee is hereby granted, provided that the above copyright notice appear in all copies 
|* and that both that copyright notice and this permission notice appear in supporting documentation. 
|*
|* Demeulemeester Filip and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 
|* Demeulemeester Filip nor Baanboard.com BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
|* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
|*
|******************************************************************************
|* Script Type: 4
|******************************************************************************
declaration:
|* form fields
extern domain tcmcs.s256	frmFrom, varfrom
extern domain tcmcs.s256	frmTo, varto
extern domain tcmcs.s256	frmSubject, varsubject
extern domain tcmcs.s256	frmBody, varbody
extern domain tcmcs.s256	frmCat, varcat
extern domain tcmcs.s256	frmBCC, varbcc
extern domain tcmcs.s256	frmCC, varcc
extern domain tcmcs.s256	frmAtt, varatt
extern domain tcmcs.s256	frmAction, varaction

functions:
function extern send_email()
{
	long   ret
	string commandline(2560)
	
	varfrom 	= """" & frmFrom & """"
	varto  	= """" & frmTo & """"
	varsubject 	= """" & frmSubject & """"
	varbody 	= """" & frmBody & """"
	varcat 	= """test"""
	varbcc 	= """bccfide"""
	varcc 	= """ccfide"""
	varatt 	= """"""
	varaction 	= """move"""	| or copy or save or send cfr script below
	
	commandline = "outlook.vbs " & varfrom & " " & varto & " " & varsubject & " " & varbody & " " & varcat & " " & varbcc & " " & varcc & " " & varatt & " " & varaction
	ret = app_start(commandline,"","","","")
}
There is also a vbs-script that is called outlook.vbs (this is just a textfile)
To use this vbs-script the path must be specified or the script must be in the system-directory:
Code:
Dim obj 
Dim nCount
Dim i
dim vfrom, vto, vsubject, vbody, vcat, vbcc, vcc, vatt, vaction

nCount = WScript.Arguments.Count
wscript.echo ncount

vfrom = cstr(Wscript.arguments(0))
vto = cstr(Wscript.arguments(1))
vsubject = cstr(Wscript.arguments(2))
vbody = cstr(Wscript.arguments(3))
vcat = cstr(Wscript.arguments(4))
vbcc = cstr(Wscript.arguments(5))
vcc = cstr(Wscript.arguments(6))
vatt = cstr(Wscript.arguments(7))
vaction = cstr(Wscript.arguments(8))

set obj = CreateObject("VBBAAN.BAANVB")
i = obj.sendBaanEmail(cstr(vfrom), cstr(vto), cstr(vsubject), cstr(vbody), cstr(vcat), cstr(vbcc), cstr(vcc), cstr(vatt), cstr(vaction))

set obj = Nothing


Last but not least there is a VB-script(activeX-dll) that process the mail:

Option Explicit

Private mOutlookApp     As Outlook.Application
Private mNameSpace      As Outlook.NameSpace
Private mOutbox         As Outlook.MAPIFolder
Private mBaanOutbox     As Outlook.MAPIFolder
Private mItem           As Outlook.MailItem

Private bOK             As Boolean
Private i               As Integer
Private pRecip          As Recipient
Private pAttachments    As Attachments

Public Function SendBaanEmail(vFrom As String, vTo As String, vSubject As String, vBody As String, vCat As String, vBCC As String, vCC As String, vAtt As String, vAction As String) As Boolean
  On Error GoTo auExit
  
  SendBaanEmail = False
  
  If GetOutlook() Then
       If CreateFolder() Then
            'Create Mail
            Set mItem = mOutlookApp.CreateItem(olMailItem)
  
            Set pRecip = mItem.Recipients.Add(vTo)
            mItem.SentOnBehalfOfName = vFrom
            mItem.Subject = vSubject
            mItem.Body = vBody
            mItem.Categories = vCat
            mItem.BCC = vBCC
            mItem.CC = vCC
    
            'Add attachment
            'Set pAttachments = mItem.Attachments
            'pAttachments.Add vAtt, olByValue
            
            Select Case vAction
            Case "move"
                mItem.Move mBaanOutbox
            Case "copy"
                mItem.Copy      'outbox
            Case "save"
                mItem.Save      'draft
            Case "send"
                mItem.Send      'inbox
            End Select
        Else
            MsgBox "Failed to create baan folders"
        End If
  End If
  Set mItem = Nothing
  Set mOutbox = Nothing
  Set mBaanOutbox = Nothing
  Set mNameSpace = Nothing
  Set mOutlookApp = Nothing
  Exit Function
auExit:
    MsgBox Err.Description
End Function

Function GetOutlook() As Boolean

  On Error Resume Next

  GetOutlook = False

  Set mOutlookApp = New Outlook.Application
  Set mNameSpace = mOutlookApp.GetNamespace("MAPI")
  If Err Then
    MsgBox "Failed to open oulook", vbCritical _
        & vbCrLf & "Error: " & Err.Number & " " & Err.Description
    Exit Function
  End If
  
  GetOutlook = True
  
End Function
    
Function CreateFolder()
    
    On Error Resume Next
    
    CreateFolder = False
    Err.Clear
    'open outbox folder
    Set mOutbox = mNameSpace.GetDefaultFolder(olFolderOutbox)
    'open or create baanoutbox folder
    i = 1
    bOK = False
    While i <= mOutbox.Folders.Count
        If mOutbox.Folders.Item(i).Name = "Outbox Baan" Then
            bOK = True
            Set mBaanOutbox = mOutbox.Folders("Outbox Baan")
        End If
        i = i + 1
    Wend
    If Not bOK Then
        Set mBaanOutbox = mOutbox.Folders.Add("Outbox Baan", olFolderInbox)
    End If
    If Err.Number = 0 Then
        CreateFolder = True
    End If
End Function
In this example he will put draft in a new created folder under the outboxfolder.
When you can make improvements ; please contact me
Reply With Quote
  #2  
Old 10th July 2002, 20:10
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,028
NPRao will become famous soon enough
Baan: iBaanERP-5.2a(Reger),SSA-ERP-LN-6.1,Infor LN-10.x - DB: Oracle-10g,11g,12c,MS-SQL - OS: HP-UX, Linux, Windows
Hi Carise,

That was very good code. I was wondering if you considered using the BaaN Tools CMF options: http://www.baanboard.com/programmers_manual_baanerp_help_emessage_connector_cmf_createrecipient
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao
Reply With Quote
  #3  
Old 10th July 2002, 23:50
carice's Avatar
carice carice is offline
Member
 
Join Date: Mar 2002
Location: Belgium
Posts: 38
carice is on a distinguished road
Baan: BaanIV; BaanV (5.0;5.1;5.2) - DB: BISAM; ORACLE - OS: WINNT; UNIX
yep

That's right ; i have considered cmf but it wasn't so flexible like mine. You can do whatever you wanted with your message in my code.
You don't have to work with a session and a form. In our company the responsible of reminders , ... will have automatically all the reminders in outlook in a special folder where he can decided to mail it or not (Just 1 example what you can do with this code).

I'm happy that you like the code although i think improvements can be done.
Reply With Quote
  #4  
Old 31st January 2008, 19:03
tnzabo's Avatar
tnzabo tnzabo is offline
Senior Member
 
Join Date: Jul 2002
Location: Butler
Posts: 189
tnzabo is on a distinguished road
Baan: BaaN IV C4 - DB: SQL Server 2005 - OS: Windows 2003 SP2
old thread revived

Hi - this code you have posted here...does this simply allow you to use a Baan session as an email session - bypassing, sort of, Outlook? How does this work if I have a session in a job that runs with no user intervention and will email the report to a user?
Reply With Quote
  #5  
Old 18th May 2011, 15:33
Mikkann's Avatar
Mikkann Mikkann is offline
Junior Member
 
Join Date: Aug 2008
Location: NN, Russian Federation
Posts: 6
Mikkann is on a distinguished road
Baan: 6.1 - DB: Oracle - OS: Unix
Very qood question - does anyone knows the solution?
Reply With Quote
Sponsored Links
  #6  
Old 12th July 2012, 11:09
bilmaa bilmaa is offline
Member
 
Join Date: Jul 2004
Location: Spain
Posts: 84
bilmaa is on a distinguished road
Baan: baan iv c4 sp20 - DB: oracle 10G - OS: win 2003
you can use other things

for example Blat utility, realy very useful utility.

teste.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NEW: vbcode CODE extensions patvdv About Baanboard.com 3 13th March 2003 11:19
CODE: Retrieve ENUM Description from SQL Server with VB Ruskin Code & Utilities 8 8th July 2002 16:37


All times are GMT +2. The time now is 11:34.


©2001-2017 - Baanboard.com - Baanforums.com