fiogf49gjkf0d
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.
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
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.
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
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
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