Alpha Media Inc

Forums for all Alpha Media Inc Software

General Developer Information

Questions regarding the implementation of PinkNotes® v4 into your system / software.

General Developer Information

Postby AlphaMedia » Mon Sep 15, 2008 12:41 pm

Whenever you want to send a message to a user, you want to open the Future.MDB file on the master computer in the C:\program files\pnp4\master\TO_USERSNAME\PNP4Fut.MDB (default)

We have provided some very basic descriptions of the fields and some basic VB6 Code, including a PNP class with all of the required properties, and methods to facilitate your job. You will find the download link below at the bottom of this post. If your environment is not VB6, we have taken the code and pasted it below. You should be able to make sense of it.. Let us know if you require any further (more detailed) instruction.

VB6 Form Code
Code: Select all
Option Explicit

Private Sub cmdSend_Click()
  On Error GoTo pnpError
 
  Dim PNP As New CPNP
 
  With PNP
    .toName = txtTo
    .fromName = txtFrom
    .subject = txtSubject
    .message = txtMessage
   
    If .SendPNP(txtDB) Then
      MsgBox "Message successfully written to database."
    End If

  End With
 
  Set PNP = Nothing
 
  Exit Sub
pnpError:
  MsgBox Err.Number & " - " & Err.Description
End Sub


VB6 Class
Code: Select all
Option Explicit

Private m_sendNow As Boolean

Private m_id As String

Private m_toMaster As String
Private m_fromMasterAddress As String

Private m_toName As String
Private m_fromName As String
Private m_carbonCopy As String

Private m_toNames() As String
Private m_carbonCopies() As String

Private m_sendDate As Date
Private m_repeat As String

Private m_urgent As Boolean
Private m_mustAcknowledge As Boolean
Private m_confidential As Boolean
Private m_subject As String

Private m_field(7) As String
Private m_checkbox(7) As Boolean

Private m_message As String
Private m_comments As String

Private m_resend As String

Private m_attachName As String
Private m_attachSize As String
Private m_attachment As String

Private Const dBirth As Date = "1/1/2000"

Public Property Let fromName(ByVal vFromName As String)
  m_fromName = vFromName
End Property

Public Property Let toName(ByVal vToName As String)
  m_toName = vToName
 
  If Len(m_toName) > 0 Then
    If Left$(m_toName, 1) <> "," Then
      m_toName = ", " & m_toName
    End If
  End If
End Property

Public Property Let carbonCopy(ByVal vCarbonCopy As String)
  m_carbonCopy = vCarbonCopy
 
  If Len(m_carbonCopy) > 0 Then
    If Left$(m_carbonCopy, 1) <> "," Then
      m_carbonCopy = ", " & m_carbonCopy
    End If
  End If
End Property

Public Property Let subject(ByVal vSubject As String)
  m_subject = vSubject
End Property

Public Property Let sendDate(ByVal vSendDate As Date)
  m_sendDate = vSendDate
End Property

Public Property Let repeat(ByVal vRepeat As String)
  m_repeat = vRepeat
End Property

Public Property Let message(ByVal vMessage As String)
  m_message = vMessage
End Property

Public Property Let urgent(ByVal vUrgent As Boolean)
  m_urgent = vUrgent
End Property

Public Property Let mustAcknowledge(ByVal vMustAcknowledge As Boolean)
  m_mustAcknowledge = vMustAcknowledge
End Property

Public Property Let confidential(ByVal vConfidential As Boolean)
  m_confidential = vConfidential
End Property

Public Function SetField(ByVal vIndex As Integer, ByVal vField As String)
  m_field(vIndex) = vField
End Function

Public Function SetCheckBox(ByVal vIndex As Integer, ByVal vCheckBox As Boolean)
  m_checkbox(vIndex) = vCheckBox
End Function

Public Function SendPNP(ByVal vPNPFutDbFilename As String) As Boolean
  On Error GoTo pnpError
 
  Dim dbsPNP As Database
 
  Set dbsPNP = OpenDatabase(vPNPFutDbFilename)
 
  dbsPNP.Execute "Insert Into Messages (sendDate, repeat, message, id, fromName) Values " & _
      "('" & m_sendDate & "', '', " & _
      "'" & Replace(SendString, "'", "''") & "', '" & m_id & "', " & _
      "'" & Replace(m_fromName, "'", "''") & "');"
 
  dbsPNP.Close
 
  SendPNP = True
 
  Exit Function
pnpError:
  MsgBox Err.Number & " - " & Err.Description
End Function

Private Function MakeID() As String
  Dim ra!, id$
  id = DateDiff("s", dBirth, Now)
 
  Randomize Timer
  ra = Int((9999 - 0 + 1) * Rnd + 0)
  MakeID = id & Trim$(Str$(ra))
End Function

Private Function SendString() As String
  SendString = IIf(m_sendNow, "1", "0") & "`~`" & m_toMaster & "`~`" & m_fromMasterAddress & _
      "`~`" & m_toName & "`~`" & m_fromName & "`~`" & m_carbonCopy & _
      "`~`" & m_sendDate & _
      "`~`" & m_repeat & _
      "`~`" & IIf(m_urgent, "1", "0") & _
      "`~`" & IIf(m_mustAcknowledge, "1", "0") & _
      "`~`" & IIf(m_confidential, "1", "0") & _
      "`~`" & m_subject & _
      "`~`" & m_field(1) & _
      "`~`" & m_field(2) & _
      "`~`" & m_field(3) & _
      "`~`" & m_field(4) & _
      "`~`" & m_field(5) & _
      "`~`" & m_field(6) & _
      "`~`" & m_field(7) & _
      "`~`" & IIf(m_checkbox(1), "1", "0") & _
      "`~`" & IIf(m_checkbox(2), "1", "0") & _
      "`~`" & IIf(m_checkbox(3), "1", "0") & _
      "`~`" & IIf(m_checkbox(4), "1", "0") & _
      "`~`" & IIf(m_checkbox(5), "1", "0") & _
      "`~`" & IIf(m_checkbox(6), "1", "0") & _
      "`~`" & IIf(m_checkbox(7), "1", "0") & _
      "`~`" & m_message & _
      "`~`" & m_resend & "`~`" & m_comments & _
      "`~`" & m_attachName & "`~`" & m_attachSize & "`~`" & m_attachment
End Function

Private Sub Class_Initialize()
  m_sendDate = Now
  m_id = MakeID
End Sub



Field Descriptions
Code: Select all
"sendDate" is the date and time the message is to be delivered
"message" is the actual message string that is sent to the PNP Clients
"id" is a random string of numbers (each id must be unique)
"fromName" is the username of the sender
"repeat" is how often the message is sent - repetition then a comma, period then a comma, and until date (this field is not required)

The easiest way to see what the database looks like is to open the PNP4Fut.mdb file is MS Access.

The 'message' itself has 32 fields of its own. With each field seperated by the following: "`~`"

Here are the fields in order:
=============================
m_sendNow (always False for Send Laters)
m_toMaster (not required for Send Laters)
m_masterAddress (not required for Send Laters)
m_toName (has commas and a space before every name)
m_fromName
m_carbonCopy (has commas and a space before every name)
m_sendDate (date and time)
m_repeat (repetition then a comma, period then a comma, and until date - not required)

m_urgent (True or False)
m_mustAcknowledge (True or False)
m_confidential (True or False)

m_subject
m_field(1 to 7)
m_checkBox(1 to 7) (True or False)

m_message (message in rich text format - does not have to be rich text format)

m_resend (only used when a message is re-sent, can be left blank for send laters)
m_comments (not used with Send Laters)
m_attachName (not used with Send Laters)
m_attachSize (not used with Send Laters)
m_attachment (not used with Send Laters)

NOTE: in the database True is a One (1) and False is a Zero (0).

Please take a look at our VB6 example code to get an idea of how this works.
Attachments
PNP4ExampleCode.zip
PNP4 Message Sending Code Sample (VB6)
(13.64 KiB) Downloaded 937 times
User avatar
AlphaMedia
Site Admin
 
Posts: 37
Joined: Mon Sep 15, 2008 10:19 am

Return to Developer Questions/Information



Who is online

Users browsing this forum: No registered users and 1 guest

cron