Thought i would show you how to send emails using visual Basic
i know theres a guide for vb.net but not seen one for vb6
Code:
On Error Resume Next
Set objnet = CreateObject("WScript.NetWork")
Set oSMTPSession = CreateObject("OSSMTP.SMTPSession")
With oSMTPSession
.MailFrom = ""
.SendTo = ""
.Server = ""
.Port = 25
.MessageSubject = ""
.MessageText = ""
.SendEmail
End With
Set oSMTPSession = Nothing
.MailFrom = "" 'can be a real email address or just anything, also can = a textbox for variable or any object which can hold text
.SendTo = "" 'Has to be real ofcourse
.Server = "" 'SMTP server of who your sending it too
.Port = 25 'Port normaly 25
.MessageSubject = "" 'Subject of Email
.MessageText = "" 'Email text
all these can = text1.text for example
now for adding attackments
General
Code:
Dim filename As String
Dim intCounter As Integer
command button to Send
Code:
On Error Resume Next
Set objnet = CreateObject("WScript.NetWork")
Set oSMTPSession = CreateObject("OSSMTP.SMTPSession")
With oSMTPSession
.MailFrom = txtFrom.Text
.SendTo = txtEmail.Text
.Server = txtServer.Text
.Port = 25
.MessageSubject = txtSubject.Text
.MessageText = txtText.Text
If intCounter >= "1" Then
Else
GoTo send
End If
'adding attachment
Set oAttachment = CreateObject("OSSMTP.Attachment")
oAttachment.FilePath = filename
oAttachment.AttachmentName = txtAname.Text
oAttachment.ContentType = "application/xml"
oAttachment.ContentTransferEncoding = 1
.Attachments.Add oAttachment
send:
.SendEmail
End With
Set oSMTPSession = Nothing
The if statement is there for when an attachment is not there becuase without it, it will only send if you add an attachment
Set oAttachment = CreateObject("OSSMTP.Attachment")
oAttachment.FilePath = filename 'location o0f attachment
oAttachment.AttachmentName = "" 'name of attachment
oAttachment.ContentType = "application/xml"
oAttachment.ContentTransferEncoding = 1
.Attachments.Add oAttachment
for adding an attachment i would add a commondialog1 which can be done by
Project -> components -> Microsoft common dialog control 6.0
then adding it to the form
then
Command button for adding attachment
Code:
commondialog1.showopen
filename = CommonDialog1.filename
you might want to add a if statment to check if filename = ""
also in that command button you need
Code:
intcounter = intcounter + 1
Here is a simple program i made
Download:
MEGAUPLOAD - The leading online storage and file delivery service
Virus Scan:
Virustotal. MD5: a29cc036331c6eff9b5fa75f9ff02bb1