[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Modify Cose To Add Authentication

Posted on 2011-10-10
1
Medium Priority
?
301 Views
Last Modified: 2012-05-12
I need to add authentication in the following code to send email.
Private Sub Command11_Click()
'On Error Resume Next

If IsNull(Message) Then
MsgBox "Please Enter A Message", vbOKOnly, "ENTER MESSAGE"
Message.SetFocus
Exit Sub

Else

Dim i As Integer
    Dim carbo As String
    Dim morgan As String
    Dim objEmail As Object
    Me.label01.Visible = True
    Command11.Caption = "Sending Page"
    Me.label01.Caption = "Paging Target"
    Me.To.Value = "Target"
    For i = 0 To lstSelected.ListCount - 1
       carbo = lstSelected.Column(2, i)
           ' Me.label01.Visible = False
           '     sl2 1
            '    Me.label01.Visible = True
             '   sl2 1
             '   Me.label01.Visible = False
             '   sl2 1
              '  Me.label01.Visible = True
        morgan = Message
      
                Set objEmail = CreateObject("CDO.Message")
                objEmail.from = "Dispatch@ozarkdale911.org"
                objEmail.To = carbo
                objEmail.subject = Me.Ref.Value
                objEmail.HTMLBody = ""
                objEmail.TextBody = morgan & vbCrLf & Environ$("USERNAME")
                
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.gl.centurytel.net"
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            objEmail.Configuration.Fields.Update
            objEmail.send
        Me.Label150.Visible = True

        Me.Label150.Caption = "Sending " & i + 1 & " " & "of" & " " & lstSelected.ListCount & " " & "pages"
        Me.Form.Caption = "Sending " & i + 1 & " " & "of" & " " & lstSelected.ListCount & " " & "pages"

       ' If Err.Number <> 0 Then
        '    MsgBox "Error in sending. " & Err.Description
        'End If
        
        Set objEmail = Nothing
    
    Next i
            
          

Me.label01.Caption = "FINISHED"
Command11.Caption = "Complete"
sl 1


Command11.Caption = "Send Page"
Me.Form.Caption = "Complete"
Me.label01.Caption = ""
Me.Label150.Caption = "Target Has Been Paged"

End If

End Sub

Open in new window

0
Comment
Question by:mickeyshelley1
1 Comment
 

Accepted Solution

by:
mickeyshelley1 earned 0 total points
ID: 36944481
Entered the following 3 lines o code    

    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "emailAddress"
        objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"

Private Sub Command11_Click()
On Error Resume Next

If IsNull(Message) Then
MsgBox "Please Enter A Message", vbOKOnly, "ENTER MESSAGE"
Message.SetFocus
Exit Sub

Else

Dim i As Integer
    Dim carbo As String
    Dim morgan As String
    Dim objEmail As Object
    Me.label01.Visible = True
    Command11.Caption = "Sending Page"
    Me.label01.Caption = "Paging Target"
    Me.To.Value = "Target"
    For i = 0 To lstSelected.ListCount - 1
       carbo = lstSelected.Column(2, i)
           ' Me.label01.Visible = False
           '     sl2 1
            '    Me.label01.Visible = True
             '   sl2 1
             '   Me.label01.Visible = False
             '   sl2 1
              '  Me.label01.Visible = True
        morgan = Message
      
                Set objEmail = CreateObject("CDO.Message")
                objEmail.from = "Dispatch@ozarkdale911.org"
                objEmail.To = carbo
                objEmail.subject = Me.Ref.Value
                objEmail.HTMLBody = ""
                objEmail.TextBody = morgan & vbCrLf & Environ$("USERNAME")
                
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.gl.centurytel.net"
            objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "EmailAddress"
        objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"

            objEmail.Configuration.Fields.Update
            objEmail.send

        Me.Label150.Visible = True

        Me.Label150.Caption = "Sending " & i + 1 & " " & "of" & " " & lstSelected.ListCount & " " & "pages"
        Me.Form.Caption = "Sending " & i + 1 & " " & "of" & " " & lstSelected.ListCount & " " & "pages"

       ' If Err.Number <> 0 Then
        '    MsgBox "Error in sending. " & Err.Description
        'End If
        
        Set objEmail = Nothing
    
    Next i
            
          

Me.label01.Caption = "FINISHED"
Command11.Caption = "Complete"
sl 1


Command11.Caption = "Send Page"
Me.Form.Caption = "Complete"
Me.label01.Caption = ""
Me.Label150.Caption = "Target Has Been Paged"

End If

End Sub

Open in new window

0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question