home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 7_2009-2012.ISO / data / zips / GRSSLSendM222365592012.psc / frmSSLSendMail.frm < prev   
Text File  |  2012-05-09  |  17KB  |  496 lines

  1. VERSION 5.00
  2. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  3. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  4. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  5. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  6. Begin VB.Form SSLForm 
  7.    BorderStyle     =   1  'Fixed Single
  8.    Caption         =   "SSL eMail Sender - Updated 2012"
  9.    ClientHeight    =   5910
  10.    ClientLeft      =   45
  11.    ClientTop       =   435
  12.    ClientWidth     =   9060
  13.    Icon            =   "frmSSLSendMail.frx":0000
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   5910
  17.    ScaleWidth      =   9060
  18.    StartUpPosition =   2  'CenterScreen
  19.    Begin ComctlLib.ProgressBar ProgressBar1 
  20.       Height          =   225
  21.       Left            =   4995
  22.       TabIndex        =   1
  23.       Top             =   5655
  24.       Visible         =   0   'False
  25.       Width           =   3975
  26.       _ExtentX        =   7011
  27.       _ExtentY        =   397
  28.       _Version        =   327682
  29.       Appearance      =   1
  30.       Min             =   1e-4
  31.    End
  32.    Begin MSComDlg.CommonDialog dlgFile 
  33.       Left            =   4800
  34.       Top             =   2760
  35.       _ExtentX        =   847
  36.       _ExtentY        =   847
  37.       _Version        =   393216
  38.    End
  39.    Begin MSWinsockLib.Winsock Winsock1 
  40.       Left            =   4320
  41.       Top             =   2760
  42.       _ExtentX        =   741
  43.       _ExtentY        =   741
  44.       _Version        =   393216
  45.    End
  46.    Begin VB.Frame frameEmail 
  47.       Height          =   5505
  48.       Left            =   30
  49.       TabIndex        =   3
  50.       Top             =   45
  51.       Width           =   8985
  52.       Begin VB.PictureBox Picture1 
  53.          BorderStyle     =   0  'None
  54.          ClipControls    =   0   'False
  55.          Height          =   5340
  56.          Left            =   75
  57.          ScaleHeight     =   5340
  58.          ScaleWidth      =   8865
  59.          TabIndex        =   4
  60.          TabStop         =   0   'False
  61.          Top             =   135
  62.          Width           =   8865
  63.          Begin VB.CommandButton cmdSend 
  64.             Caption         =   "&Send"
  65.             Height          =   375
  66.             Left            =   6960
  67.             TabIndex        =   21
  68.             Top             =   885
  69.             Width           =   1815
  70.          End
  71.          Begin VB.TextBox txtSubject 
  72.             Height          =   285
  73.             Left            =   735
  74.             TabIndex        =   12
  75.             Text            =   "Testing SSL connection"
  76.             Top             =   540
  77.             Width           =   5655
  78.          End
  79.          Begin VB.TextBox txtTo 
  80.             Height          =   285
  81.             Left            =   735
  82.             TabIndex        =   11
  83.             Text            =   "giorock@teletu.it"
  84.             Top             =   900
  85.             Width           =   5655
  86.          End
  87.          Begin VB.TextBox txtFrom 
  88.             Height          =   285
  89.             Left            =   735
  90.             TabIndex        =   10
  91.             Top             =   180
  92.             Width           =   5655
  93.          End
  94.          Begin VB.TextBox txtBCC 
  95.             Height          =   285
  96.             Left            =   735
  97.             TabIndex        =   9
  98.             Text            =   "giorock@libero.it"
  99.             Top             =   1620
  100.             Width           =   5655
  101.          End
  102.          Begin VB.TextBox txtCC 
  103.             Height          =   285
  104.             Left            =   735
  105.             TabIndex        =   8
  106.             Text            =   "rockadmin@teletu.it"
  107.             Top             =   1260
  108.             Width           =   5655
  109.          End
  110.          Begin VB.TextBox txtMessage 
  111.             Height          =   3000
  112.             Left            =   255
  113.             MultiLine       =   -1  'True
  114.             ScrollBars      =   2  'Vertical
  115.             TabIndex        =   7
  116.             Text            =   "frmSSLSendMail.frx":0622
  117.             Top             =   2220
  118.             Width           =   8520
  119.          End
  120.          Begin VB.CommandButton cmdSetting 
  121.             Caption         =   "&Setting"
  122.             Height          =   375
  123.             Left            =   6960
  124.             TabIndex        =   6
  125.             Top             =   1365
  126.             Width           =   1815
  127.          End
  128.          Begin VB.CommandButton cmdAttachments 
  129.             Caption         =   "Add &Attachment"
  130.             Height          =   375
  131.             Left            =   6960
  132.             TabIndex        =   5
  133.             Top             =   405
  134.             Width           =   1815
  135.          End
  136.          Begin VB.Image Image2 
  137.             Height          =   240
  138.             Left            =   6630
  139.             Picture         =   "frmSSLSendMail.frx":0692
  140.             Top             =   952
  141.             Width           =   240
  142.          End
  143.          Begin VB.Line Line2 
  144.             BorderColor     =   &H8000000C&
  145.             X1              =   6660
  146.             X2              =   8730
  147.             Y1              =   1860
  148.             Y2              =   1860
  149.          End
  150.          Begin VB.Label Label1 
  151.             Alignment       =   2  'Center
  152.             Caption         =   "GioRock 2012"
  153.             BeginProperty Font 
  154.                Name            =   "Bookman Old Style"
  155.                Size            =   12
  156.                Charset         =   0
  157.                Weight          =   600
  158.                Underline       =   0   'False
  159.                Italic          =   -1  'True
  160.                Strikethrough   =   0   'False
  161.             EndProperty
  162.             ForeColor       =   &H8000000D&
  163.             Height          =   285
  164.             Left            =   6525
  165.             MouseIcon       =   "frmSSLSendMail.frx":0CB4
  166.             MousePointer    =   99  'Custom
  167.             TabIndex        =   20
  168.             ToolTipText     =   "go to Author Site..."
  169.             Top             =   60
  170.             Width           =   2235
  171.          End
  172.          Begin VB.Image Image3 
  173.             Height          =   240
  174.             Left            =   6630
  175.             Picture         =   "frmSSLSendMail.frx":0E06
  176.             Top             =   1432
  177.             Width           =   240
  178.          End
  179.          Begin VB.Image Image1 
  180.             Height          =   240
  181.             Left            =   6630
  182.             Picture         =   "frmSSLSendMail.frx":1428
  183.             Top             =   472
  184.             Width           =   240
  185.          End
  186.          Begin VB.Label lblAttachments 
  187.             ForeColor       =   &H00FF0000&
  188.             Height          =   255
  189.             Left            =   1320
  190.             TabIndex        =   19
  191.             Top             =   1965
  192.             Width           =   7455
  193.          End
  194.          Begin VB.Image Image11 
  195.             Height          =   240
  196.             Left            =   -15
  197.             Picture         =   "frmSSLSendMail.frx":1A4A
  198.             Top             =   3600
  199.             Width           =   240
  200.          End
  201.          Begin VB.Image Image10 
  202.             Height          =   240
  203.             Left            =   -15
  204.             Picture         =   "frmSSLSendMail.frx":206C
  205.             Top             =   1972
  206.             Width           =   240
  207.          End
  208.          Begin VB.Image Image9 
  209.             Height          =   240
  210.             Left            =   -15
  211.             Picture         =   "frmSSLSendMail.frx":268E
  212.             Top             =   562
  213.             Width           =   240
  214.          End
  215.          Begin VB.Image Image8 
  216.             Height          =   240
  217.             Left            =   -15
  218.             Picture         =   "frmSSLSendMail.frx":2CB0
  219.             Top             =   1642
  220.             Width           =   240
  221.          End
  222.          Begin VB.Image Image7 
  223.             Height          =   240
  224.             Left            =   -15
  225.             Picture         =   "frmSSLSendMail.frx":32D2
  226.             Top             =   1282
  227.             Width           =   240
  228.          End
  229.          Begin VB.Image Image6 
  230.             Height          =   240
  231.             Left            =   -15
  232.             Picture         =   "frmSSLSendMail.frx":36F4
  233.             Top             =   922
  234.             Width           =   240
  235.          End
  236.          Begin VB.Image Image5 
  237.             Height          =   240
  238.             Left            =   -15
  239.             Picture         =   "frmSSLSendMail.frx":3D16
  240.             Top             =   202
  241.             Width           =   240
  242.          End
  243.          Begin VB.Label Label2 
  244.             AutoSize        =   -1  'True
  245.             Caption         =   "To:"
  246.             Height          =   195
  247.             Left            =   420
  248.             TabIndex        =   18
  249.             Top             =   945
  250.             Width           =   240
  251.          End
  252.          Begin VB.Label Label4 
  253.             AutoSize        =   -1  'True
  254.             Caption         =   "Sub:"
  255.             Height          =   195
  256.             Left            =   330
  257.             TabIndex        =   17
  258.             Top             =   585
  259.             Width           =   330
  260.          End
  261.          Begin VB.Label Label5 
  262.             AutoSize        =   -1  'True
  263.             Caption         =   "From:"
  264.             Height          =   195
  265.             Left            =   270
  266.             TabIndex        =   16
  267.             Top             =   225
  268.             Width           =   390
  269.          End
  270.          Begin VB.Label Label6 
  271.             AutoSize        =   -1  'True
  272.             Caption         =   "BCC:"
  273.             Height          =   195
  274.             Left            =   300
  275.             TabIndex        =   15
  276.             Top             =   1665
  277.             Width           =   360
  278.          End
  279.          Begin VB.Label Label7 
  280.             AutoSize        =   -1  'True
  281.             Caption         =   "CC:"
  282.             Height          =   195
  283.             Left            =   405
  284.             TabIndex        =   14
  285.             Top             =   1305
  286.             Width           =   255
  287.          End
  288.          Begin VB.Label Label8 
  289.             Caption         =   "Attachments:"
  290.             Height          =   255
  291.             Left            =   315
  292.             TabIndex        =   13
  293.             Top             =   1965
  294.             Width           =   975
  295.          End
  296.          Begin VB.Line Line1 
  297.             BorderColor     =   &H80000009&
  298.             BorderWidth     =   2
  299.             X1              =   6630
  300.             X2              =   8730
  301.             Y1              =   1875
  302.             Y2              =   1875
  303.          End
  304.       End
  305.    End
  306.    Begin ComctlLib.StatusBar StatusBar1 
  307.       Align           =   2  'Align Bottom
  308.       Height          =   315
  309.       Left            =   0
  310.       TabIndex        =   0
  311.       Top             =   5595
  312.       Width           =   9060
  313.       _ExtentX        =   15981
  314.       _ExtentY        =   556
  315.       SimpleText      =   ""
  316.       _Version        =   327682
  317.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  318.          NumPanels       =   2
  319.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  320.             Object.Width           =   8643
  321.             MinWidth        =   8643
  322.             Text            =   "Status: Ready to send an eMail"
  323.             TextSave        =   "Status: Ready to send an eMail"
  324.             Key             =   ""
  325.             Object.Tag             =   ""
  326.          EndProperty
  327.          BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  328.             Object.Width           =   8643
  329.             MinWidth        =   8643
  330.             TextSave        =   ""
  331.             Key             =   ""
  332.             Object.Tag             =   ""
  333.          EndProperty
  334.       EndProperty
  335.    End
  336.    Begin RichTextLib.RichTextBox RichTextBox1 
  337.       Height          =   480
  338.       Left            =   6810
  339.       TabIndex        =   2
  340.       Top             =   1935
  341.       Width           =   480
  342.       _ExtentX        =   847
  343.       _ExtentY        =   847
  344.       _Version        =   393217
  345.       TextRTF         =   $"frmSSLSendMail.frx":4338
  346.    End
  347.    Begin VB.Image Image4 
  348.       Height          =   240
  349.       Left            =   6495
  350.       Picture         =   "frmSSLSendMail.frx":43BA
  351.       Top             =   2055
  352.       Width           =   240
  353.    End
  354. End
  355. Attribute VB_Name = "SSLForm"
  356. Attribute VB_GlobalNameSpace = False
  357. Attribute VB_Creatable = False
  358. Attribute VB_PredeclaredId = True
  359. Attribute VB_Exposed = False
  360. Option Explicit
  361. '********************************
  362. '*      SSL eMail Sender        *
  363. '********************************
  364. '*   Created by GioRock 2009    *
  365. '*     giorock@libero.it        *
  366. '********************************
  367.  
  368. '********************************************
  369. '*               UPDATED  2012              *
  370. '********************************************
  371.  
  372. '******************NEWS**********************
  373. '*    NOW RSA KEY CERTIFIED V3 SUPPORTED    *
  374. '*     ENABLE TO HANDSHAKE WITH SSL3.0      *
  375. '*     SERVER MUST BE ABLE TO FALLBACK      *
  376. '*       AT SSL2.0 PROTOCOL INTERFACE       *
  377. '********************************************
  378.  
  379. 'WARNING:
  380. 'THIS PROGRAM IS ONLY TESTED ON HOTMAIL SERVER
  381. 'PARAMS:
  382. '       SERVER NAME
  383. '       PORT
  384. '       USERID
  385. '       PASSWORD
  386. '       ACCESS BY SERVER AUTHENTICATION
  387. '       SSL -> TRUE
  388. 'NOT DISCLAIMS ARE ACCEPTED USING OTHER CONFIGURATIONS OR DIFFERENT SERVERS
  389.  
  390. 'YOU CAN ADAPT ALL CODE TO WORK ON OTHER SERVERS
  391.  
  392. 'TODO:
  393. 'MUCH MORE....
  394.  
  395. Private Type SHITEMID
  396.     cb As Long
  397.     abID As Byte
  398. End Type
  399.  
  400. Private Type ITEMIDLIST
  401.     mkid As SHITEMID
  402. End Type
  403.  
  404. Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
  405. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
  406. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  407.  
  408. Private Type tagInitCommonControlsEx
  409.    lngSize As Long
  410.    lngICC As Long
  411. End Type
  412.  
  413. Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As tagInitCommonControlsEx) As Boolean
  414. Private Const ICC_USEREX_CLASSES = &H200
  415.  
  416. Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  417. Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  418. Private Const CS_DROPSHADOW As Long = &H20000
  419. Private Const GCL_STYLE     As Long = -26
  420.  
  421. Private Mail As SSLSocket
  422.  
  423. Private Sub ApplyDropShadow(ByVal hWnd As Long)
  424.     Me.Hide
  425.     DoEvents
  426.     Call SetClassLong(hWnd, GCL_STYLE, GetClassLong(hWnd, GCL_STYLE) Or CS_DROPSHADOW)
  427.     Me.Show
  428. End Sub
  429.  
  430. Private Function MyDocuments() As String
  431.     Dim r As Long
  432.     Dim IDL As ITEMIDLIST
  433.     Dim Path As String
  434.     'Get the special folder
  435.     r = SHGetSpecialFolderLocation(100, &H5, IDL)
  436.     If r = 0 Then
  437.         'Create a buffer
  438.         Path$ = Space$(512)
  439.         'Get the path from the IDList
  440.         r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
  441.         'Remove the unnecessary chr$(0)'s
  442.         MyDocuments = Left$(Path, InStr(Path, Chr$(0)) - 1)
  443.         Exit Function
  444.     End If
  445.  
  446. End Function
  447. Private Sub cmdAttachments_Click()
  448.     Dim pstrFolder As String
  449.     Dim pstrFilePath As String
  450.     Dim pstrFile As String
  451.     Dim pintI As Integer
  452.     Dim pstrLabel As String
  453.     
  454.     Screen.MousePointer = vbHourglass
  455.     pstrFolder = MyDocuments
  456.     
  457.     On Error GoTo ErrorCall
  458.     
  459.     With dlgFile
  460.         .CancelError = True
  461.         .InitDir = MyDocuments
  462.         .ShowOpen
  463.         pstrFilePath = .Filename
  464.     End With
  465.     
  466.     StatusBar1.Panels(1).Text = "Status: Adding File..."
  467.     DoEvents
  468.     
  469.     If Mail Is Nothing Then: Set Mail = New SSLSocket
  470.     
  471.     ProgressBar1.Visible = True
  472.     Call Mail.AddAttachment(pstrFilePath, ProgressBar1)
  473.     
  474.     pintI = InStrRev(pstrFilePath, "\")
  475.     pstrFile = Mid(pstrFilePath, pintI + 1)
  476.     pstrLabel = lblAttachments.Caption
  477.     
  478.     If pstrLabel <> "" Then
  479.         pstrLabel = pstrLabel & ", "
  480.     End If
  481.     
  482.     txtMessage.Top = lblAttachments.Top + lblAttachments.Height
  483.     pstrLabel = pstrLabel & pstrFile
  484.     lblAttachments.Caption = pstrLabel
  485.     ProgressBar1.Visible = False
  486.     
  487.     Screen.MousePointer = vbNormal
  488.     
  489.     Exit Sub
  490.  
  491. ErrorCall:
  492.     If Err.Number = 32755 Then
  493.         Screen.MousePointer = vbNormal
  494.         Exit Sub
  495.     Else
  496.         Call MsgBox(Err.Number & "' " & Err.Description,           s,Err.D