• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Agent needed to create a single mail with attachment from the personal n&a


i bought a sms service.
sending a mail to the sms provider , the provider will send out this mail as a sms.

the format of this mail is not so nice.

i tried it manaull, it works.
now i look for a smarter solution.

i'm in my personal n&a on a persons record.
now i want to press a button ...or something else...and this mail is created automatically.

mail format:
- the subject needed to be allways the same predefined text.
- so use e.g.  yxcvb123  as  the subject
- the address / sendto is also allways the same, so please use e.g. "john@sms.com"
- attachment:
   an attachment is needed, content as plain text
   name of the attachment:  beispiel.csv

- content of the attachment

49           = country code  (will be allways the same = 49)
174         = area code
2893611 = phone number
Martin;Miller;  = senders name, allways the same = Martin;Miller;

my idea is that the agent should look at the document field:  CellPhoneNumber
and takes the needed information out of this filed.
if you look at this filed, you see 0174-2893611   in the persons record.

  • 3
  • 2
  • 2
  • +1
1 Solution
Sjef BosmanGroupware ConsultantCommented:
You want some hints, or the full solution? I assume you didn't start developing this yet, but the working solution is far from trivial. The hints:
- I'd use LotusScript to do this
- most of the commands to be used are pretty straightforward
- create a NotesDocument to store the mail temporarily
- to create an attachment you need to have a temp. directory
- use Open and Print to write to that file
- create the necessary fields, including a RichText Body field
- attach the file, and unlink it
- send the mail out

It's a substantial piece of coding, for which I haven't got the time...

Viel Erfolg!
hreinartAuthor Commented:
i want the full solution
Try this ready made solution and make necessary changes to fit your need


Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

hreinartAuthor Commented:
did you check if attachments are created, too?  ...in the way i need it?
SMS is simple text msg mail. I don't think that they can handle attachments ? Do they ? I never used SMS !
Sjef BosmanGroupware ConsultantCommented:
Sounds to me you need a job done, not "some" assistance. I suppose we'd all love to send you a bill for a full solution, but that's way beyond the scope of my (unpaid) activities in this site anyway.

Maybe someone else...
hreinartAuthor Commented:
..so please read my needs in the question.   the attachment is needed, please read above, thanks
Jean Marie GeeraertsApplication EngineerCommented:
This agent isn't too complicate to write.

1) Create an agent and set the properties to
- Run 'From Action Menu'
- Run on 'Selected Documents'
- Run LotusScript

2) Select the people for which you want to send an SMS and then select the agent from the action menu

Here's the code for the agent:

Sub Initialize
      'first define fixed values, we define them in constans so they are easier to adjust afterwards
      Const COUNTRY_CODE = "49"
      Const SMS_SENDTO = "john@sms.com"
      Const SMS_SUBJECT = "fixed subject"
      Const SMS_SENDER_FIRST_NAME = "Martin"
      Const SMS_SENDER_LAST_NAME = "Miller"
      Const TMP_FILE = "c:\temp\beispiel.csv"
      'initialize local variables
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim dc As NotesDocumentCollection
      Dim docPerson As NotesDocument
      Dim docMail As NotesDocument
      Dim strZone As String 'holds the location number and country code
      Dim strPhone As String 'holds the phone number
      Dim strCellPhone As String 'used to hold the full phone number from the person document
      Dim FileNum As Integer
      Dim rtBody As NotesRichTextItem
      'get reference to the selected documents from the address book
      Set db = session.CurrentDatabase
      Set dc = db.UnprocessedDocuments
      'walk through all selected documents and create a mail per document
      If dc.Count = 0 Then Exit Sub
      Set docPerson = dc.GetFirstDocument
      Do While Not docPerson Is Nothing
            'get phone number
            strCellPhone = docPerson.CellPhoneNumber(0)
            strZone = Left$(strCellPhone, Instr(strCellPhone, "-")-1)
            strZone = COUNTRY_CODE & Right$(strZone, Len(strZone)-1)
            strPhone = Right$(strCellPhone, Len(strCellPhone) - Instr(strCellPhone, "-"))
            'write temporary file
            FileNum = Freefile
            Open TMP_FILE For Output As FileNum
            Print #FileNum, strZone & ";" & strPhone & ";" & SMS_SENDER_FIRST_NAME & ";" & SMS_SENDER_LAST_NAME & ";"
            Close FileNum
            'create mail and attach the file
            Set docMail = db.CreateDocument
            With docMail
                  .SendTo = SMS_SENDTO
                  .Subject = SMS_SUBJECT
                  'create the body field to hold the attachment
                  Set rtBody = .CreateRichTextItem("Body")
                  'attach the file as a regular attachment
                  Call rtBody.Embedobject(1454, "", TMP_FILE)
                  'send the mail
            End With
            Set docPerson = dc.GetNextDocument(docPerson)
End Sub

The agent supposes that the mobile number is always stored in the format you specified. No fancy translation implemented, so make sure the CellPhoneNumber is correct before you run the agent. I didn't include any validation checks.

If you run into any trouble, let me know.

Kind regards,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now