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

POP3 attachments

Does any one know how to to upload attachments to a pop3 mail server, i know how to send and recieve mail ok its just the attatchments i dunno about.
Have searched planetsourcecode but can't find any working code to do this.
thanks
0
crazyman
Asked:
crazyman
  • 7
  • 6
  • 3
1 Solution
 
JuiletteCommented:
0
 
mcriderCommented:
POP3 Mail Servers do not receive data, they only send data to clients.  If you want to send mail with or without attachments, you need to use SMTP or IMAP4...

In either event, the attachment is just part of the message...

Cheers!
0
 
crazymanAuthor Commented:
Juliette:I searched that site i couldnt find anything on attatchments ...maybe i missed something.

mcrider:I assumed they were both POP3 because i was using the same server to send and recieve..i guess it runs both on differant ports?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
JuiletteCommented:
search box Other
           Attachments
0
 
JuiletteCommented:
0
 
mcriderCommented:
Yes, POP3 operates on port 110 and SMTP operates on port 25

Here's what you would send via SMTP once you've connected:


   HELO your_ip_address
   MAIL FROM: <your_email_Address@wherever.com>
   RCPT TO: <destination_email_address@whereever.com>
   DATA
   SUBJECT: The Subject
   DATE: The Date
   Freestyle body text
   uuencoded attachment
   .

Anywhere you see "less than" and "greater than" symbols above, you actually need to use them. Each line above is terminated with a VBCRLF.

Cheers!
0
 
crazymanAuthor Commented:
how do i do this uuencode?
0
 
mcriderCommented:
Here's a url to an ActiveX uuencode/decode object:

   http://www.miken.com/uud/uudev.htm
 
I haven't actually tried it... But it's free.  I bought my routine a couple of years ago....


Cheers!
0
 
mcriderCommented:
By the way, once you've uuencoded the file, just put 2 blank lines after the freestyle body text and the send the uuencoded file....


Cheers!
0
 
crazymanAuthor Commented:
When you say send the file you mean open it and send it as text?
If this is the case then i just get the data in the email text not as an attatchment..ive searched hio and low for a working example ..found some that dont work but i cant find any good documentation on this.
Anyone?
0
 
mcriderCommented:
Here is a working example I have coded for you.  The following is "Form1.frm". Copy it in it's entirety using notepad and save it as form1.frm, then start VB, remove the default form1 and add this one.

Remember, to send a file as an attachment, it must already be uuencoded.

Cheers!


THE CODE:


VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   7965
   ClientLeft      =   3045
   ClientTop       =   2070
   ClientWidth     =   6915
   LinkTopic       =   "Form1"
   ScaleHeight     =   7965
   ScaleWidth      =   6915
   Begin VB.TextBox Text1
      Height          =   285
      Left            =   1200
      TabIndex        =   0
      Text            =   "Text1"
      ToolTipText     =   "  Enter the NAME or the IP Address of your Mail Gateway here.  "
      Top             =   120
      Width           =   5535
   End
   Begin VB.TextBox Text7
      BackColor       =   &H00C0C0C0&
      Height          =   1935
      Left            =   1200
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   7
      Text            =   "Form1.frx":0000
      ToolTipText     =   "  This is the status window.  "
      Top             =   5400
      Width           =   5535
   End
   Begin VB.TextBox Text6
      Height          =   285
      Left            =   1200
      TabIndex        =   5
      Text            =   "Text6"
      ToolTipText     =   "  Enter the path of the UUENCODED file to send as an attachment here.  "
      Top             =   4200
      Width           =   5535
   End
   Begin VB.TextBox Text5
      Height          =   2325
      Left            =   1200
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   4
      Text            =   "Form1.frx":0008
      ToolTipText     =   "  Enter the message body here.  "
      Top             =   1680
      Width           =   5535
   End
   Begin VB.TextBox Text4
      Height          =   285
      Left            =   1200
      TabIndex        =   3
      Text            =   "Text4"
      ToolTipText     =   "  Enter the SUBJECT of the message here.  "
      Top             =   1200
      Width           =   5535
   End
   Begin VB.TextBox Text3
      Height          =   285
      Left            =   1200
      TabIndex        =   2
      Text            =   "Text3"
      ToolTipText     =   "  Enter the TO ADDRESS of the message here.  "
      Top             =   840
      Width           =   5535
   End
   Begin VB.CommandButton Command1
      Caption         =   "SEND"
      Height          =   495
      Left            =   3120
      TabIndex        =   6
      ToolTipText     =   "  Click here to send the message.  "
      Top             =   4680
      Width           =   1215
   End
   Begin VB.TextBox Text2
      Height          =   285
      Left            =   1200
      TabIndex        =   1
      Text            =   "Text2"
      ToolTipText     =   "  Enter the FROM ADDRESS of the message here.  "
      Top             =   480
      Width           =   5535
   End
   Begin MSWinsockLib.Winsock Winsock1
      Left            =   120
      Top             =   5160
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   327681
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "Mail Server:"
      Height          =   255
      Index           =   5
      Left            =   120
      TabIndex        =   13
      Top             =   120
      Width           =   975
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "Attachment:"
      Height          =   255
      Index           =   4
      Left            =   120
      TabIndex        =   12
      Top             =   4200
      Width           =   975
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "Message:"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   11
      Top             =   1680
      Width           =   975
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "Subject:"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   10
      Top             =   1200
      Width           =   975
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "To:"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   9
      Top             =   840
      Width           =   975
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      Caption         =   "From:"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   8
      Top             =   480
      Width           =   975
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Sub SendMessage(FromAddr As String, ToAddr As String, Subject As String, Msg As String, Attachment As String)
    Dim fNum As Integer
    Dim AttachData As String
   
    With Winsock1
        .SendData "HELO " + CStr(.LocalIP) + vbCrLf
        DoEvents
        .SendData "MAIL FROM: <" + FromAddr + ">" + vbCrLf
        DoEvents
        .SendData "RCPT TO: <" + ToAddr + ">" + vbCrLf
        DoEvents
        .SendData "DATA" + vbCrLf
        DoEvents
        .SendData "SUBJECT: " + Subject + vbCrLf
        DoEvents
        .SendData "FROM: " + FromAddr + vbCrLf
        DoEvents
        .SendData "DATE: " + CStr(Now) + vbCrLf + vbCrLf
        DoEvents
        .SendData Msg + vbCrLf + vbCrLf + vbCrLf
        DoEvents
        If Not Attachment = "" Then
            DoEvents
            Text7.Text = Text7.Text + "Sending attachment... Please wait..." + vbCrLf
            fNum = FreeFile
            Open Attachment For Binary Access Read As fNum
            AttachData = Space(LOF(fNum))
            Get #fNum, , AttachData
            Close #fNum
            .SendData AttachData
            DoEvents
        End If
        .SendData vbCrLf + vbCrLf + "." + vbCrLf
        DoEvents
        .SendData "QUIT" + vbCrLf
        DoEvents
    End With
End Sub

Private Sub Command1_Click()
    If Not Trim$(Text6.Text) = "" Then
        If Dir(Text6.Text) = "" Then
            MsgBox "Cant find attached file!", vbCritical
            Exit Sub
        End If
    End If
    Text7.Text = "Connecting to " + Text1.Text + vbCrLf
    With Winsock1
        .RemoteHost = Text1.Text
        .RemotePort = 25
        .Connect
    End With
End Sub


Private Sub Form_Load()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    MsgBox "This is a demo program that will connect to an SMTP" + vbCrLf + _
        "Mail Server and send an E-Mail with an optional Attachment." + vbCrLf + vbCrLf + _
        "When sending an attachment, the file must already be UUENCODED." + vbCrLf + _
        "There are several " + Chr$(34) + "Freeware" + Chr$(34) + " uuencode/uudecode programs" + vbCrLf + _
        "available on the market." + vbCrLf + vbCrLf + _
        "ToolTips are enabled on all of the fields... Cheers!"
       
End Sub

Private Sub Winsock1_Close()
    Text7.Text = Text7.Text + "Connection Closed." + vbCrLf
    Winsock1.Close
    MsgBox "Connection Closed."
End Sub

Private Sub Winsock1_Connect()
    Text7.Text = Text7.Text + "Connected, sending message..." + vbCrLf
    SendMessage Text2.Text, Text3.Text, Text4.Text, Text5.Text, Text6.Text
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim xBuf As String
    Winsock1.GetData xBuf, vbString
    Text7.Text = Text7.Text + xBuf
    DoEvents
End Sub


0
 
crazymanAuthor Commented:
I already solved it myself by the time i read this
0
 
mcriderCommented:
So what did you do? Did you use any of my code?
0
 
crazymanAuthor Commented:
I figure this would have worked so ill award the points,thanks for your time.
0
 
crazymanAuthor Commented:
I figured you deserved the points for your time.
0
 
mcriderCommented:
Thanks for the points!

Cheers!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 7
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now