-
December 22nd, 2011, 10:44 AM
#31
Re: sending e-mail through VB application
The question is 8 years old! I doubt the poster is still searching for a solution.
Aside from that the answer just posted is not using the correct language so it would not help even if the poster was still looking.
Always use [code][/code] tags when posting code.
-
December 22nd, 2011, 11:12 AM
#32
Re: sending e-mail through VB application
AND there are no code tags!
-
December 29th, 2011, 06:55 PM
#33
Re: sending e-mail through VB application
This works OK- but it sends mail the before the user can enter text into the body. I'd like to bring up Outlook, start an empty Email , fill in the TO: address, subject, and maybe a line of two in the Body, then allow the user to fill in the rest of the body of the message, then send it, after they finish typing it.
I've looked in the FAQ and the Five Ways to send email- they are variations on yoru method. I can't get the command line completion to work on the objOutlook object, so I cant see the other methods.
Hi,
why don't you use vbsendmail.dll .you can send mail without outlook !.Just download the vbsendMail.dll from following web site .and place VbsendMail.dll into system32 folder .
http://www.freevbcode.com/ShowCode.asp?ID=109.
step 2.
just copy vbsendmail.dll it into sytem32 folder .
step 3
register this using regsvr32
step 4
write the following declaration in the general section of your form .where you want to use this code .
Code:
Private WithEvents poSendMail As vbSendMail.clsSendMail
Private Function SendMail()
Set poSendMail = New vbSendMail.clsSendMail
poSendMail.SMTPHost = "SMTP.GMAIL.COM" 'here smtp server
poSendMail.From = "firoz.raj@gmail.com" 'From where y want to send .
poSendMail.FromDisplayName = "FEEROZE"
poSendMail.RecipientDisplayName = "xx;mm" 'Put receipients Name
poSendMail.Recipient = ""firoz.raj@gmx.com"[/COLOR]]firoz.raj@gmx.com " 'Type your Receipient name .to whom y want to send
poSendMail.CcDisplayName = "Wof;Datamiser;David" 'Write Carbon copy as per your convenience
poSendMail.CcRecipient = " " ' in this property you can write Recipient Email
poSendMail.Subject = "Email Demo" 'You can type subject in subject property of PosendMail object.
poSendMail.message = "please find your attachment "
poSendMail.Attachment = "C:\Log\" & Attachment FileName
poSendMail.Send
Set poSendMail = Nothing
End Function:wave::wave:
Last edited by firoz.raj; December 29th, 2011 at 07:00 PM.
-
December 29th, 2011, 10:09 PM
#34
Re: sending e-mail through VB application
Once again someone posting to an 8 year old thread, would be nice if people would take the time to look at other posts and perhaps even the date of the post before pulling a long dead thread back to the top of the list.
Always use [code][/code] tags when posting code.
-
December 29th, 2011, 10:26 PM
#35
Re: sending e-mail through VB application
No longer recommended, as too many people had problems. (Or OUTLOOK was changed after Office 2000) Should actually TRY the code, before you post it for others to follow
AND:
.SMTPHost = "SMTP.GMAIL.COM" 'here smtp server
poSendMail.From = "firoz.raj@gmail.com" 'From where y want to send .
poSendMail.FromDisplayName = "FEEROZE"
poSendMail.RecipientDisplayName = "xx;mm" 'Put receipients Name
poSendMail.Recipient = ""firoz.raj@gmx.com"[/color]]firoz.raj@gmx.com " 'Type your Receipient name .to whom y want to send
poSendMail.CcDisplayName = "Wof;Datamiser;David" 'Write Carbon copy as per your convenience
poSendMail.
Should be the last straw...
Last edited by dglienna; December 29th, 2011 at 10:28 PM.
-
December 30th, 2011, 12:46 AM
#36
Re: sending e-mail through VB application
Here is a Simple way to do this, No Outlook required, No win-socket Required.
Just add this Library to your project and use this function for send emails from VB applications.
Microsoft CDO for Windows 2000 Library
Code:
Public Sub SendEMail(lTo As String, LSubject As String, lAttchCount As Integer, lBody As String, Optional SingalFile As String, Optional lAttchements)
On Error GoTo erh
Dim Correio As CDO.Message
Set Correio = CreateObject("CDO.Message")
Correio.From = """ABC Org"" <abc@gmail.com>"
Correio.To = lTo
Correio.BCC = "jkl@gmail.com, mno@gmail.com"
Correio.Subject = LSubject
Correio.TextBody = lBody
If lAttchCount = 1 Then
Correio.AddAttachment SingalFile
End If
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "abc@gmail.com"
Correio.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "abc123"
Correio.Configuration.Fields.Update
Correio.Send
Exit Sub
erh:
MsgBox Err.Description, vbApplicationModal + vbInformation, "My App"
Exit Sub
End Sub
I'M BACK AGAIN !!
-------------------------------------------------------------------------
enjoy the VB !
If any post helps you, please rate that.
Always try to findout the Solutions, instead just discussing the problem and its scope!
-
January 20th, 2012, 05:35 AM
#37
Re: sending e-mail through VB application
hello i used below code but still error 530 5.7.0 must issue a STARTTLS command first.
Code:
Dim UserName$, UserMail$, MailRecipiant$, MailBody$, SockData$
Private Sub Command1_Click()
UserName = "leonscott136@gmail.com"
UserMail = "leonscott136<leonscott136@gmail.com>"
MailRecipiant = UserMail
MailBody = "The message goes here"
Winsock1.LocalPort = 0
Winsock1.RemoteHost = "smtp.gmail.com"
Winsock1.RemotePort = 587
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
Label1 = "Sending message..."
Winsock1.SendData "EHLO " & UserName & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "MAIL FROM: " & UserMail & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "RCPT TO: " & MailRecipiant & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "DATA" & vbCrLf
If Not WaitFor("354") Then GoTo 100
Winsock1.SendData MailBody & vbCrLf & "." & vbCrLf
If Not WaitFor("250") Then GoTo 100
Winsock1.SendData "QUIT" & vbCrLf
If Not WaitFor("221") Then GoTo 100
Label1 = "Message sent"
GoTo 200
100
Label1 = SockData
200
Winsock1.Close
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData SockData
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Label1 = "Error: " & Description
SockData = "Error"
Winsock1.Close
End Sub
Private Function WaitFor(SockResponse As String) As Boolean
Do While Left(SockData, 3) <> SockResponse And Left(SockData, 3) <> "220" And Left(SockData, 3) <> "250"
DoEvents
If Left(SockData, 3) > "400" Then Exit Function
Loop
WaitFor = 1
SockData = ""
End Function
iam trying to send mail to gmail anybody tell me what i put wrong above code
Last edited by WizBang; January 20th, 2012 at 11:29 PM.
Reason: Added [code] tags
-
January 20th, 2012, 06:39 AM
#38
Re: sending e-mail through VB application
You should describe in more detail what happens or what happens NOT.
Have you verified that a connection to smtp.gmail.com has been established?
-
January 20th, 2012, 01:43 PM
#39
Re: sending e-mail through VB application
Originally Posted by leonscott136
hello i used below code but still error 530 5.7.0 must issue a STARTTLS command first.
Also, IIRC this error message does not necessarily mean your SMTP implementation is faulty. (I didn't closely examine your code though, one of the reasons being that it's pretty hard to read without the code tags.) It may just mean that the server you're connecting to requires you to use TLS but your SMTP implementation doesn't support that.
I have no experience with smtp.gmail.com, so I don't know whether that should work without TLS. I suggest you run a test with a server of which you know for sure that it doesn't require TLS. I'm afraid though that, in case that actually is the problem, implementing the entire TLS protocol yourself in VB6 would be a lot of work...
HTH
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
January 20th, 2012, 05:40 PM
#40
Re: sending e-mail through VB application
This thread is too old to keep repeating the same thing...
-
January 20th, 2012, 11:47 PM
#41
Re: sending e-mail through VB application
@leonscott136:
That Winsock code looks a lot like what I've posted in the past. I believe it fails because gmail requires a secure connection (causing the TLS related error). This document details what needs to be done: https://tools.ietf.org/html/rfc3207
Whether you'd be able to fulfill the requirements using only Winsock is another matter. It may work with some servers and not others. I've not pursued it, but I suspect it'd require more work than it's probably worth.
Last edited by WizBang; January 20th, 2012 at 11:51 PM.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|