Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, November 23, 2024 
 
Using the SalesLogix Mail Client to Send E-mail  
Description:  This article outlines how you can utilize the SalesLogix Mail Client to send e-mail from SalesLogix VBScripts. Learn to create code to send an email to any mail server supported by the SalesLogix Mail Client. This includes MAPI, Extended MAPI, VIM, SMTP, etc

Category:  SalesLogix VBScript Articles
Author:  Stephen Redmond
Submitted:  6/14/2003
   
Stats: 
Article has been read 40417 times

Rating: - 4.5 out of 5 by 8 users
 

fiogf49gjkf0d
Introduction

In previous versions of SalesLogix to 6.0 the SalesLogix Mail Client was actually a COM object that was available for developers to utilize. Unfortunately, one of it’s main methods used a Boolean variable and it was not possible to successfully call an external method from Enable (legacy) Basic that used a Boolean variable.

Now, with version 6.x and VBScript, it is very possible.

This allows you to create code to send an email to any mail server supported by the SalesLogix Mail Client. This includes MAPI, Extended MAPI, VIM, SMTP, etc.

Mail Connection

The Mail Connection component creates a link to the SalesLogix Mail Client.

You create the MailConnection object using CreateObject:

    Set MailConnection = CreateObject("SLMailClient.MailConnection")    

We can then confirm if we have a connection:

    MailConnection.IsConnected    

Mail Object

We create a mail session by creating an instance of the mail connection’s Mail object.

    Set MailSession = MailConnection.Mail    

We can then use this session to send an email.

Mail Constants

This is a list of the constants needed for sending an email:

Public Const MF_TO = 1
Public Const MF_SUBJECT = 4
Public Const MF_RECEIPT = 7
Public Const MF_PRIORITY = 8
Public Const MF_FROM = 0
Public Const MF_DATE = 9
Public Const MF_CC = 2
Public Const MF_BODY = 5
Public Const MF_BCC = 3
Public Const MF_ATTACH = 6

Public Const MERR_DB = 1
Public Const MERR_DRIVER = 2
Public Const MERR_NOTIMPLEMENTED = 3
Public Const MERR_SYS = 0

Public Const MP_HIGH = 2
Public Const MP_LOW = 0
Public Const MP_NORMAL = 1

Sending an E-mail

We send an email by creating an array of variants and then setting the relevant index items to the correct value. The possible index values are 0 to 9 and correspond with the constants above:

MF_TO          1      To address
MF_SUBJECT     4      Subject
MF_RECEIPT     7      Receipt required
MF_PRIORITY    8      Mail priority
MF_FROM        0      From address
MF_DATE        9      Date of email
MF_CC          2      CC address
MF_BODY        5      Body of the email (text)
MF_BCC         3      BCC address
MF_ATTACH      6      Path to attachment

You need to set all of the options. E.g.:

MailArray(MF_TO) = "john.abbott@abbotmanuf.com"
MailArray(MF_FROM) = "lee@phoenixmotors.com"
MailArray(MF_SUBJECT) = "Price List"
MailArray(MF_PRIORITY) = MP_NORMAL
MailArray(MF_BODY) = "Hi John,  Here is our latest prices."
MailArray(MF_RECEIPT) = 0
MailArray(MF_CC) = ""
MailArray(MF_BCC) = ""
MailArray(MF_DATE) = Now
MailArray(MF_ATTACH) = "C:\Temp\Price.xls" 

Once you have set the array values, you can then call the Send method of the mail session object, setting whether to save the email, true or false:

    MailSession.Send MailConnection.SessionID, MailArray, True    

Example Function

Public Const MF_TO = 1
Public Const MF_SUBJECT = 4
Public Const MF_RECEIPT = 7
Public Const MF_PRIORITY = 8
Public Const MF_FROM = 0
Public Const MF_DATE = 9
Public Const MF_CC = 2
Public Const MF_BODY = 5
Public Const MF_BCC = 3
Public Const MF_ATTACH = 6

Public Const MP_HIGH = 2
Public Const MP_LOW = 0
Public Const MP_NORMAL = 1

Sub SendMail(sFrom, sTo, sSubject, iPriority, sBody, iReceipt, sCC, sBCC, dDate, sAttachment)

    Dim MailConnection
    Dim MailSession
    Dim b()
    ReDim b(9)

    b(MF_TO) = sTo
    b(MF_FROM) = sFrom
    b(MF_SUBJECT) = sSubject
    b(MF_PRIORITY) = iPriority
    b(MF_BODY) = sBody
    b(MF_RECEIPT) = iReceipt
    b(MF_CC) = sCC
    b(MF_BCC) = sBCC
    b(MF_DATE) = dDate
    b(MF_ATTACH) = sAttachment

    Set MailConnection = CreateObject("SLMailClient.MailConnection")
    Set MailSession = MailConnection.Mail

    MailSession.Send MailConnection.SessionID, b, True

    Set MailSession = Nothing
    Set MailConnection = Nothing

End Sub    


 

About the Author

  Stephen Redmond
(SalesLogix Business Partner)
Capricorn Ventis Ltd.

fiogf49gjkf0d
Author of the excellent DevLogix - A Guide to SalesLogix Development (now in 5th edition).


View online profile for Stephen Redmond
 

[ back to top] [ send to a friend]  

Rate This Article you must log-in to rate articles. [login here] 
 
Please log in to rate article.
 

Comments & Discussion you must log-in to add comments. [login here] 
 
Author Article Comments and Discussion
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Great info Stephen
Posted: 6/14/2003 12:26:08 AM
fiogf49gjkf0d
I didn't even know you could use the SalesLogix Mail Client to do this. Great info.

-Ryan
 
Stephen Redmond



Re: Great info
Posted: 6/17/2003 2:32:55 PM
fiogf49gjkf0d
Thanks Ryan.

I've known about this for about 3 years! Unfortunately it just wouldn't work in v4.


Stephen
 
Daniel Chibaya
 

Thanks for the Info.
Posted: 7/28/2003 10:29:19 AM
fiogf49gjkf0d
Thanks for the info Stephen. Could something similar work in the slx VER 5.X

-Daniel
 
David Saggio
 

Great tip
Posted: 9/30/2003 2:10:37 PM
fiogf49gjkf0d
Thanks Ryan,

This really came in handy. BTW, what are the other methods for the mail session object? Or do you have any other documentation on the object?

-Dave
 
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Re: Great tip...
Posted: 10/6/2003 12:57:02 AM
fiogf49gjkf0d
Dave, I can't take credit for this one, this was by Stephen Redmond. But to answer your question, you could look at the available methods or properties in any object browser, such as the one that is built in to VB. Looking at the MailConnection object discussed in this article, you'd look at the objects exposed by the file "SLMailClient.exe". Here's a dump of the methods exposed there (although you'd really want to look at it with an object browser - I'm only posting the methods, not the properties etc. Also I am not posting anything from the "Mail" class which would be useful to use since that is where all the events are defined)

Dispatch
IMailConnection
{624DDEA2-70F1-11D1-B877-0000B4552A26}
Version 1.0
Functions

Mail
Help string: Pointer to global mail object
Connected
Help string: Do we have a connection ?
LastComposeResult
Help string: Get Last Compose Modal Result as Integer
SessionID
Help string: Session (OLE Auto Client) ID as Integer
AddrBookFieldCount
Setup
Help string: Execute Mail Setup Dialog as Integer
LogOn
Help string: LogOn into Mail system as Integer
LogOff
Help string: LogOff from mail system as Integer
Send
Help string: Send Mail as Integer
Parameters
aSave
SetMailField
Help string: Set Mail Field by Field ID as Integer
Parameters
aField
Value
GetMailField
Help string: Get Mail Field by Field ID as Integer
Parameters
aField
EngineOn
Help string: Create MailEngine Object as Integer
EngineOff
Help string: Destroy MailEngine Object as Integer
UIOn
Help string: Show Main Form Object as Integer
UIOff
Help string: Hide Main Form Object as Integer
Compose
Help string: Open Compose window Object as Integer
Parameters
aSave
IsCompose
Help string: Is Compose window open as Integer
Parameters
aID
About
Help string: About Info window open as Integer
DeliverNow
Help string: Deliver Now window open s Integer
AddrBookUIOn
Help string: Show Address Book UI as Integer
AddAddressBook
Help string: Add Address Book UI as Integer
Parameters
aName
aFile
aReadOnly
DelAddressBook
Help string: Delete Address Book as Integer
Parameters
aName
UpdAddressBook
Help string: Update Address Book as Integer
Parameters
aName
aRecords
ZapAddressBook
Help string: Clear all records in Address Book as Integer
Parameters
aName
AddrBookRecipientsUIOn
Parameters
OwnerWnd
Field
Recipients

Hope this helps - Ryan
 
Ivan



Re: Using the SalesLogix Mail Client to Send E-mail
Posted: 4/28/2008 12:10:16 AM
fiogf49gjkf0d
Hello, Stephen! Hello, Ryan!

How to add into a letter this header: "content-type:text/plain; charset=.cp1251 "? (for the Russian language)
 
Onam Díaz



Re: Using the SalesLogix Mail Client to Send E-mail
Posted: 9/24/2008 6:34:32 PM
fiogf49gjkf0d
Hi,
I need send E-Mail, using smtp without MS outlook, how do it?
i have server smtp, port, user, password...

thanks
sorry by my english
 
 

       Visit the slxdeveloper.com Community Forums!
Not finding the information you need here? Try the forums! Get help from others in the community, share your expertise, get what you need from the slxdeveloper.com community. Go to the forums...
 



 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/23/2024 6:12:18 PM