home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / USENET / PAPERBOY / SOURCE.ZIP / FRMMAIL.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-02  |  6.4 KB  |  203 lines

  1. VERSION 2.00
  2. Begin Form frmmail 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Send Email"
  5.    ClientHeight    =   5304
  6.    ClientLeft      =   2088
  7.    ClientTop       =   2400
  8.    ClientWidth     =   6084
  9.    Height          =   5724
  10.    Left            =   2040
  11.    LinkTopic       =   "Form1"
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   5304
  14.    ScaleWidth      =   6084
  15.    Top             =   2028
  16.    Width           =   6180
  17.    Begin CommandButton cmdcancel 
  18.       Caption         =   "&Cancel"
  19.       Height          =   372
  20.       Left            =   2760
  21.       TabIndex        =   6
  22.       Top             =   4800
  23.       Width           =   972
  24.    End
  25.    Begin CommandButton cmdsend 
  26.       Caption         =   "&Send"
  27.       Enabled         =   0   'False
  28.       Height          =   372
  29.       Left            =   1080
  30.       TabIndex        =   5
  31.       Top             =   4800
  32.       Width           =   972
  33.    End
  34.    Begin TextBox txtmsg 
  35.       Height          =   3252
  36.       Left            =   120
  37.       MultiLine       =   -1  'True
  38.       ScrollBars      =   2  'Vertical
  39.       TabIndex        =   4
  40.       Top             =   1320
  41.       Width           =   5292
  42.    End
  43.    Begin TextBox txtsubj 
  44.       BorderStyle     =   0  'None
  45.       Height          =   372
  46.       Left            =   1200
  47.       TabIndex        =   3
  48.       Top             =   720
  49.       Width           =   3852
  50.    End
  51.    Begin TextBox txtto 
  52.       BorderStyle     =   0  'None
  53.       Height          =   372
  54.       Left            =   1200
  55.       TabIndex        =   2
  56.       Top             =   120
  57.       Width           =   3852
  58.    End
  59.    Begin Label Label2 
  60.       BackColor       =   &H00C0C0C0&
  61.       Caption         =   "Subject:"
  62.       DataField       =   "Subject:"
  63.       Height          =   372
  64.       Left            =   120
  65.       TabIndex        =   0
  66.       Top             =   720
  67.       Width           =   1092
  68.    End
  69.    Begin Label Label1 
  70.       BackColor       =   &H00C0C0C0&
  71.       Caption         =   "To:"
  72.       Height          =   372
  73.       Left            =   120
  74.       TabIndex        =   1
  75.       Top             =   120
  76.       Width           =   1092
  77.    End
  78. Option Explicit
  79. Sub cmdcancel_Click ()
  80. Dim result As Integer
  81.     If Len(txtmsg.Text) > 0 Then
  82.         result = MsgBox("You will lose any text you entered." + Chr(10) + "Are you sure?", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, "Abort message?")
  83.         If result = IDYES Then Unload frmmail
  84.     Else
  85.         Unload frmmail
  86.     End If
  87. End Sub
  88. Sub cmdsend_Click ()
  89. Dim uniq As Integer, result As Integer
  90. Dim fout As Integer
  91. Dim fname As String
  92. Dim ptr, column As Integer
  93. Dim msg As String
  94. Dim replyto, organization As String
  95.     msg = txtmsg.Text
  96. ' Get a unique filename (PBR00N.MSG)
  97.     uniq = Val(GetINI("Message", "LastMessage", "1"))
  98.     uniq = uniq + 1
  99.     SetINI "Message", "LastMessage", Format$(uniq)
  100.     If replytype = 1 Then
  101.         fname = app.Path + "\PBM" + Format$(uniq, "000") + ".MSG"
  102.     Else
  103.         fname = app.Path + "\PBN" + Format$(uniq, "000") + ".MSG"
  104.     End If
  105.     fout = FreeFile
  106.     Open fname For Output As fout
  107. ' Do headers
  108.     If replytype = 1 Then
  109.         Print #fout, "To: " + txtto.Text
  110.     Else
  111.         Print #fout, "Newsgroups: " + txtto.Text
  112.     End If
  113.     Print #fout, "Subject: " + txtsubj.Text
  114.     If UCase$(GetINI("Message", "PostDate", "Y")) = "Y" Then Print #fout, "Date: " + fixstr(GetGMTime())
  115.     If mailreferences <> "" Then Print #fout, "References: " + mailreferences
  116. ' Optional Reply-To
  117.     replyto = GetINI("Message", "Reply-To", "")
  118.     If Len(replyto) > 2 Then Print #fout, "Reply-To: " + replyto
  119. ' Optional Organization
  120.     organization = GetINI("Message", "Organization", "")
  121.     If Len(organization) > 2 Then Print #fout, "Organization: " + organization
  122. ' Dump message to a file
  123.     Print #fout,    ' Blank line seperates headers from message
  124.     For ptr = 1 To Len(msg)
  125.         column = column + 1
  126.         If column > 70 And Mid$(msg, ptr, 1) = " " Then
  127.         ' Wrap line
  128.             Print #fout,
  129.             column = 0
  130.         Else
  131.             Print #fout, Mid$(msg, ptr, 1);
  132.         End If
  133.     Next ptr
  134.     Close fout
  135.     result = Post(fname, replytype) 'post mail or news
  136.     ' Ask about editing again?
  137.     Unload frmmail
  138. End Sub
  139. Sub Form_Load ()
  140. Dim sigfname As String
  141. Dim sigout As Integer
  142. Dim sigline As String
  143.     frmmail.Width = frmmain.Width * .8
  144.     frmmail.Height = frmmain.Height * .8
  145.     frmmail.Left = (screen.Width - frmmail.Width) / 2
  146.     frmmail.Top = (screen.Height - frmmail.Height) / 2
  147.     txtsubj = mailsubject
  148.     txtto = mailsendto
  149.     Form_resize
  150.     If replytype = 1 Then
  151.         label1.Caption = "To:"
  152.         frmmail.Caption = "Send Email"
  153.         cmdsend.Caption = "&Send"
  154.     Else
  155.         label1.Caption = "Newsgroup:"
  156.         frmmail.Caption = "Post News"
  157.         cmdsend.Caption = "&Post"
  158.     End If
  159.     ' Do signature
  160.     sigfname = GetINI("Message", "Signature-File", app.Path + "\SIG.TXT")
  161.     If FileExists(sigfname) Then
  162.         sigout = FreeFile
  163.         Open sigfname For Input As sigout
  164.         txtmsg.Text = txtmsg.Text + Chr(13) + Chr(10) + "-- " + Chr(13) + Chr(10)
  165.         While Not EOF(sigout)
  166.             Line Input #sigout, sigline
  167.             txtmsg.Text = txtmsg.Text + sigline + Chr(13) + Chr(10)
  168.         Wend
  169.         Close sigout
  170.         Else
  171.             ' Default signature ?
  172.     End If
  173. End Sub
  174. Sub Form_Paint ()
  175.     If txtto = "" Then
  176.         txtto.SetFocus
  177.     ElseIf txtsubj = "" Then
  178.         txtsubj.SetFocus
  179.     Else
  180.         txtmsg.SetFocus
  181.     End If
  182. End Sub
  183. Sub Form_resize ()
  184.     txtto.Width = frmmail.ScaleWidth - txtto.Left - 50
  185.     txtmsg.Width = frmmail.ScaleWidth - txtmsg.Left * 2
  186.     txtsubj.Width = txtto.Width
  187.     cmdcancel.Top = frmmail.ScaleHeight - cmdsend.Height
  188.     cmdsend.Top = cmdcancel.Top
  189.     txtmsg.Height = cmdcancel.Top - txtmsg.Top
  190. End Sub
  191. Sub test ()
  192. Dim x As Integer
  193. Dim z As Integer
  194.        x = Shell("notepad.exe") ' Modify path as needed.
  195.        While GetModuleUsage(x) > 0    ' Has Shelled program finished?
  196.           z = DoEvents()              ' If not, yield to Windows.
  197.        Wend
  198.        MsgBox "Shelled application just terminated", 64
  199. End Sub
  200. Sub txtto_Change ()
  201.     If Len(Trim(txtto.Text)) > 0 Then cmdsend.Enabled = True Else cmdsend.Enabled = False
  202. End Sub
  203.