Home

Cardbox

 
Cardbox > Support > Knowledge Base > Sending emails from Cardbox ...

Sending a single record directly from Cardbox

This sample macro takes the currently displayed record and emails it to an address that you enter. This is useful if you are doing searches on behalf of other people and want to send them the results. You can modify it in various ways: for instance, you can send any images in the record as attachments to your email, and you can send the whole selection of records instead of just the current record.

Before you use this macro, set up the details of your own email address and your mail server (SMTP server) by using Tools > Options > Email.

To use this macro:

The sample macro

Option Explicit Dim recipient,subject recipient=InputBox("Enter email address of recipient") If recipient="" Then Halt subject=InputBox("Enter subject line of email") If subject="" Then Halt Dim sender Set sender=EmailSender sender.Subject=subject Dim fmt : fmt=cbxWriteFormatPRN+cbxWriteOptionOmitBlank+cbxWriteOptionInfiniteWidth sender.Message=Records.WriteToString(fmt,Format,RecordPosition,RecordPosition) sender.Send recipient

Errors

If something goes wrong with communication with the SMTP server then the macro will terminate with an error message which should let you work out what the trouble is.

If you try to send a message to a non-existent email address then you will not normally receive an error from the macro, but you will later receive an email saying that the message could not be delivered.

Alternative: using a different format

The sample macro uses the currently active format. If you prefer to send the record using a different Cardbox format, put its name (in quotation marks) in place of the word Format in the WriteToString command.

Alternative: sending all the records in the current selection

To send all the records in the current selection, instead of just the current record, then instead of

sender.Message=Records.WriteToString(fmt,Format,RecordPosition,RecordPosition)

in the sample macro, use

sender.Message=Records.WriteToString(fmt,Format)

Extension: send attached images along with the record

If you want to send the images attached to a record along with the record itself, add the following lines just before the sender.Send command:

Dim img For Each img In ActiveRecord.Images sender.AttachImage img Next

or if you are sending all selected records rather than just the current record,

Dim rec,img For Each rec in Records For Each img In rec.Images sender.AttachImage img Next Next
© 2016 Martin Kochanski
"Cardbox" is a registered trademark.
 Top of page