SetFrom

Sets the return address of the mail message.

Description

Note: This method is for VBScript only. It is not available for Perl.

When using a CQMailMsg object to send e-mail:

  • On Windows™ systems, the default return address is the user's email address as it is specified in their email options (for example, myname@us.hcl.com).
  • On UNIX™ systems and Linux™, the default return address is not the user's email address (for example, myname@servername.domainname.hcl.com) and is dependent on the sendmail program configuration. The string value passed in to the SetFrom method may also be modified depending on the sendmail program configuration.

The CQMailMsg object can be used in a hook, and the hook may execute on a Web server or an installed HCL Compass client. Since the process identity of these two cases may not be the same, the information available to the mail transport agent (for Windows) or sendmail program (for the UNIX system and Linux) to determine what goes in the From address may be different for these two situations. You can use the SetFrom method to specify a name (such as the return value of the GetUserEmail method of the Session object), but the mail transport agent or sendmail configuration may modify or replace that value.

Note: The SetFrom method has no effect when using MAPI. When sending SMTP email on a Web server, the server name and domain may be included in the "From" part of the message (depending how the sendmail program is configured) instead of the HCL Compass user email address, unless SetFrom is explicitly used.
Attention: HCL Compass Email 1.x and MAPI support have been deprecated. For enhanced email support, use the EmailPlus 2.1 package.

Syntax

VBScript


MailMsg.SetFrom returnAddress 
Identifier
Description
MailMsg
A Mail Message object, representing the mail message to be sent.
returnAddress
A String containing the email address to add to the From field of the mail message.
Return value
None.

Examples

VBScript


Dim OleMailMsg

' Session and logon needed if GetUserEmail is used. For example, 
' Dim sessionObj
' Set sessionObj = GetSession
' sessionObj.UserLogon loginname, password, dbName, AD_PRIVATE_SESSION, ""

Set OleMailMsg = CreateObject("PAINET.MAILMSG")

msg_from = "admin@example.com"
OleMailMsg.SetFrom(msg_from)

msg_to = "admin@example.com"
OleMailMsg.AddTo(msg_to)

' You must log in to a database session if GetUserEmail is used.
msg_cc = "user_email_address"
' Or this: msg_cc = sessionObj.GetUserEmail
OleMailMsg.AddCc(msg_cc)

msg_subject = "Hello"
OleMailMsg.SetSubject(msg_subject)

msg_body = "This message brought to you from cqole!\n"
OleMailMsg.SetBody(msg_body)

OleMailMsg.Deliver