How to sent Mail in VB6.0
-
Hi, I have worked email option in vb6.0. Its only working for gmail smtp server. I want to sent from my offical mail server... Plz Help me... This is code for ur knowldge... Dim iMsg As Object Dim iConf As Object Dim Flds As Variant Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = txtUsername.Text .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = txtPass.Text .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 25 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = txtPort.Text .Update End With 'strbody = "Your Sample message " With iMsg Set .Configuration = iConf .To = txtTO.Text .CC = txtCC.Text .BCC = txtBCC.Text .From = txtUsername.Text '.From = "<your mailid to be displayed as@gmail.com>" .Subject = txtSUb.Text .TextBody = txtBody.Text .Send MsgBox ("Sent")
Yours, KaNNaN ----------------------------------------------------------------- "Success is When Ur Signature Becomes An Autograph"
If your code works fine with google as you say, then i suspect there is a configuration difference between your official mail server and google. What is your official mail server? Does it use the same port? Does it use the same authentication? Answer those and we might be able to help more. P.S. if you are developing a new application, or are learning, then it is time to move to a .Net language. VB6 is almost obsolete, and should only be used to support legacy apps, not new stuff.
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com -
Hi, I have worked email option in vb6.0. Its only working for gmail smtp server. I want to sent from my offical mail server... Plz Help me... This is code for ur knowldge... Dim iMsg As Object Dim iConf As Object Dim Flds As Variant Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = txtUsername.Text .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = txtPass.Text .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 25 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = txtPort.Text .Update End With 'strbody = "Your Sample message " With iMsg Set .Configuration = iConf .To = txtTO.Text .CC = txtCC.Text .BCC = txtBCC.Text .From = txtUsername.Text '.From = "<your mailid to be displayed as@gmail.com>" .Subject = txtSUb.Text .TextBody = txtBody.Text .Send MsgBox ("Sent")
Yours, KaNNaN ----------------------------------------------------------------- "Success is When Ur Signature Becomes An Autograph"
it been a while since i looked at VB6. but where do you confure the mail server ? i would start looking there as i cant see this info in the code provided
-
What is the point of answering the OP in such a fashion ? Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously. Some people have the unenviable task of maintaining legacy apps written in out of date languages. This has nothing to do with their skill as a programmer, or their value as a Code Project member, just a basic fact of life. The OP asked a genuine question (to which you obviously have no knowledge of the language he is using or the methods that he is trying to use ), he also showed us his code he working on, and explained his problem in terms anyone could understand. I realise that you are an accountant, and not a programmer, but if you go through your answers that you are providing on this forum, I feel that maybe until Code Project opens up an accounting Forum, you should stick to the lounge where your contributions are much more appreciated. I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
zimvbcoder wrote:
Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously.
If the OP goes and searches google / CP for the answer it has helped him.
zimvbcoder wrote:
Some people have the unenviable task of maintaining legacy apps written in out of date languages.
True, but DD asked why he was using VB6. In my opinion a valid question. If the OP responds with 'it's a legacy program' then we can move on. But if he responds with 'it's the only thing I know for this new program' we can tell him not to use it and spend some time learning .NET since VB6 isn't supported anymore.
zimvbcoder wrote:
I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
My supply of liquid Nitrogen has run out so... ;P . Seriously tho I don't think your gonna get flamed for just expressing your opinion. As to being pushed away from this site, why? If the answer(s) you get don't apply or answer the question ask for more explanation. If it was insulting vote appropriately (also if not insulting) If the answer is truly so bad that you feel personally attacked go to 'site bugs / suggestions' and ask Chris to have a look at it.
-
What is the point of answering the OP in such a fashion ? Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously. Some people have the unenviable task of maintaining legacy apps written in out of date languages. This has nothing to do with their skill as a programmer, or their value as a Code Project member, just a basic fact of life. The OP asked a genuine question (to which you obviously have no knowledge of the language he is using or the methods that he is trying to use ), he also showed us his code he working on, and explained his problem in terms anyone could understand. I realise that you are an accountant, and not a programmer, but if you go through your answers that you are providing on this forum, I feel that maybe until Code Project opens up an accounting Forum, you should stick to the lounge where your contributions are much more appreciated. I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
I think you have over reacted to Dave's post as his points are valid. I also do think you are right in what you have said and Dave could have phrased him point better. Yes, VB6 is effectively obsolete, and has been since the release of VB.NET in 2002. "I'm coding for a legacy VB6 system", is not necessarily a valid excuse for coding in VB6. If I was adding a new module to a legacy VB6 project, I would write the new module in .NET and make it COM visible, especially where the .NET functionality, for the task required, is far better than that of VB.6, which in the case of email, it is. At the end of the day, as a programmer/developer, the language you should use is that that best fits the project requirements.
Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.
-
What is the point of answering the OP in such a fashion ? Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously. Some people have the unenviable task of maintaining legacy apps written in out of date languages. This has nothing to do with their skill as a programmer, or their value as a Code Project member, just a basic fact of life. The OP asked a genuine question (to which you obviously have no knowledge of the language he is using or the methods that he is trying to use ), he also showed us his code he working on, and explained his problem in terms anyone could understand. I realise that you are an accountant, and not a programmer, but if you go through your answers that you are providing on this forum, I feel that maybe until Code Project opens up an accounting Forum, you should stick to the lounge where your contributions are much more appreciated. I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
Actually it is an ongoing problem with Indian Based members. I would estimate (fairly accurately and conservatively) that most (90%) questions that require VB6 as a solution are generated from our Indian brethren. I have a theory about that. I think that Indian schools/colleges only have vb6 software. For some reason (probably financial), they have not moved on to VB.NET, and thus they are teaching VB6. This is evident in the afternoons (London Time) when the 'kids' are CPing their homework. (Even more so when end of term projects have to be handed in). So my moan about VB6 is valid, perhaps the Indian Education authorities ought to use some of the Many Billions of Pounds that Britain gives them every year to upgrade the teaching software rather than do Space Launches. As for my bitching about google, it too is a valid point. Before I ask for help here I have googled and attempted, and for such topics as Mailing, I googled and found several million sites dedicated to the problem. Why you think I was being difficult I do not know. As for you assertation about legacy code, rubbish! Additional requirements can still be written in VB.Net and applied to old code. And if a module needs to be rewritten, then rewrite, the skeleton is there in VB6, so it is only rejigging rather than a 'From Scratch'. Thanks for keeping me on my toes though.
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
Hi, I have worked email option in vb6.0. Its only working for gmail smtp server. I want to sent from my offical mail server... Plz Help me... This is code for ur knowldge... Dim iMsg As Object Dim iConf As Object Dim Flds As Variant Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = txtUsername.Text .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = txtPass.Text .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 25 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = txtPort.Text .Update End With 'strbody = "Your Sample message " With iMsg Set .Configuration = iConf .To = txtTO.Text .CC = txtCC.Text .BCC = txtBCC.Text .From = txtUsername.Text '.From = "<your mailid to be displayed as@gmail.com>" .Subject = txtSUb.Text .TextBody = txtBody.Text .Send MsgBox ("Sent")
Yours, KaNNaN ----------------------------------------------------------------- "Success is When Ur Signature Becomes An Autograph"
Hey Kannan, Use this class, which i use for the same from VB
Option Explicit
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
' In order to use the Delivery Status Notifications (Return
' Receipt and Delivery Disposition requests)
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delayPrivate mvarCONNECTION_TIMEOUT As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Password As String 'local copy
Private mvarMail_UserName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarSMTP_ServerName As String 'local copy
Private mvarSMTP_ServerPort As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Attachments As Variant 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_FromName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_To As String 'local copy
Private mvarMail_Cc As String 'local copy
Private mvarMail_Bcc As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Subject As String 'local copy
Private mvarMail_Message As String 'local copy
Public Property Let Mail_Message(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Message = 5
10 mvarMail_Message = vData
End PropertyPublic Property Get Mail_Message() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Mail_Message
10 Mail_Message = mvarMail_Message
End PropertyPublic Property Let Mail_Subject(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Subject = 5
10 mvarMail_Subject = vData
End PropertyPublic Property Get Mail_Subject() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X -
zimvbcoder wrote:
Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously.
If the OP goes and searches google / CP for the answer it has helped him.
zimvbcoder wrote:
Some people have the unenviable task of maintaining legacy apps written in out of date languages.
True, but DD asked why he was using VB6. In my opinion a valid question. If the OP responds with 'it's a legacy program' then we can move on. But if he responds with 'it's the only thing I know for this new program' we can tell him not to use it and spend some time learning .NET since VB6 isn't supported anymore.
zimvbcoder wrote:
I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
My supply of liquid Nitrogen has run out so... ;P . Seriously tho I don't think your gonna get flamed for just expressing your opinion. As to being pushed away from this site, why? If the answer(s) you get don't apply or answer the question ask for more explanation. If it was insulting vote appropriately (also if not insulting) If the answer is truly so bad that you feel personally attacked go to 'site bugs / suggestions' and ask Chris to have a look at it.
Tom Deketelaere wrote:
If the OP goes and searches google / CP for the answer it has helped him.
Yah, teach a man to make fire, or set a man to fire - it's always a dilemma :)
Tom Deketelaere wrote:
True, but DD asked why he was using VB6. In my opinion a valid question.
I can understand where the sentiment is coming from; nearly every VB6-question has two or three answers stating that one should "move on", whilst the programmer rarely has a choice in the language being used.
Tom Deketelaere wrote:
since VB6 isn't supported anymore.
It's no longer actively supported by Microsoft. The community however, is a somewhat different beast. I'd even support 16-bit Delphi apps if required :)
Tom Deketelaere wrote:
If the answer is truly so bad
Some of our members talk/type with an enormous passion for this trade, and sometimes that gets confused with anger. The arguments are the best proof that they care about what they do :)
I are Troll :suss:
-
Hey Kannan, Use this class, which i use for the same from VB
Option Explicit
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
' In order to use the Delivery Status Notifications (Return
' Receipt and Delivery Disposition requests)
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delayPrivate mvarCONNECTION_TIMEOUT As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Password As String 'local copy
Private mvarMail_UserName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarSMTP_ServerName As String 'local copy
Private mvarSMTP_ServerPort As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Attachments As Variant 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_FromName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_To As String 'local copy
Private mvarMail_Cc As String 'local copy
Private mvarMail_Bcc As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Subject As String 'local copy
Private mvarMail_Message As String 'local copy
Public Property Let Mail_Message(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Message = 5
10 mvarMail_Message = vData
End PropertyPublic Property Get Mail_Message() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Mail_Message
10 Mail_Message = mvarMail_Message
End PropertyPublic Property Let Mail_Subject(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Subject = 5
10 mvarMail_Subject = vData
End PropertyPublic Property Get Mail_Subject() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print XShort, Snappy and does the trick! I still prefer mailto: :)
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
Tom Deketelaere wrote:
If the OP goes and searches google / CP for the answer it has helped him.
Yah, teach a man to make fire, or set a man to fire - it's always a dilemma :)
Tom Deketelaere wrote:
True, but DD asked why he was using VB6. In my opinion a valid question.
I can understand where the sentiment is coming from; nearly every VB6-question has two or three answers stating that one should "move on", whilst the programmer rarely has a choice in the language being used.
Tom Deketelaere wrote:
since VB6 isn't supported anymore.
It's no longer actively supported by Microsoft. The community however, is a somewhat different beast. I'd even support 16-bit Delphi apps if required :)
Tom Deketelaere wrote:
If the answer is truly so bad
Some of our members talk/type with an enormous passion for this trade, and sometimes that gets confused with anger. The arguments are the best proof that they care about what they do :)
I are Troll :suss:
Eddy Vluggen wrote:
Yah, teach a man to make fire, or set a man to fire - it's always a dilemma
Where's the dilemma? It's always set a man to fire ;P
Eddy Vluggen wrote:
I can understand where the sentiment is coming from; nearly every VB6-question has two or three answers stating that one should "move on", whilst the programmer rarely has a choice in the language being used.
True, but it doesn't hurt to ask why he is using VB6, like I said if the answer is, it's the only thing I know for this new program, then we can tell him to move on. I understand supporting legacy program's all to well (have one left that I haven't converted yet so ...) but new program's shouldn't be written in vb6
Eddy Vluggen wrote:
It's no longer actively supported by Microsoft. The community however, is a somewhat different beast.
Are you calling Bob a beast? ;P (watch out for those hamsters now)
Eddy Vluggen wrote:
I'd even support 16-bit Delphi apps if required
Showing your age here? :)
-
Eddy Vluggen wrote:
Yah, teach a man to make fire, or set a man to fire - it's always a dilemma
Where's the dilemma? It's always set a man to fire ;P
Eddy Vluggen wrote:
I can understand where the sentiment is coming from; nearly every VB6-question has two or three answers stating that one should "move on", whilst the programmer rarely has a choice in the language being used.
True, but it doesn't hurt to ask why he is using VB6, like I said if the answer is, it's the only thing I know for this new program, then we can tell him to move on. I understand supporting legacy program's all to well (have one left that I haven't converted yet so ...) but new program's shouldn't be written in vb6
Eddy Vluggen wrote:
It's no longer actively supported by Microsoft. The community however, is a somewhat different beast.
Are you calling Bob a beast? ;P (watch out for those hamsters now)
Eddy Vluggen wrote:
I'd even support 16-bit Delphi apps if required
Showing your age here? :)
Tom Deketelaere wrote:
Where's the dilemma? It's always set a man to fire
Efficiency. If you teach a man to make fire, then he can set others' around him on fire :)
Tom Deketelaere wrote:
it doesn't hurt to ask why he is using VB6, like I said if the answer is, it's the only thing I know for this new program, then we can tell him to move on.
That would be on the assumption that there's an option. He might have the time to learn something new, or perhaps one of the managers doesn't like the idea of a .NET framework on their clients.
Tom Deketelaere wrote:
but new program's shouldn't be written in vb6
Not from a programmers perspective :thumbsup:
I are Troll :suss:
-
Hey Kannan, Use this class, which i use for the same from VB
Option Explicit
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
' In order to use the Delivery Status Notifications (Return
' Receipt and Delivery Disposition requests)
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delayPrivate mvarCONNECTION_TIMEOUT As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Password As String 'local copy
Private mvarMail_UserName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarSMTP_ServerName As String 'local copy
Private mvarSMTP_ServerPort As Integer 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Attachments As Variant 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_FromName As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_To As String 'local copy
Private mvarMail_Cc As String 'local copy
Private mvarMail_Bcc As String 'local copy
'local variable(s) to hold property value(s)
Private mvarMail_Subject As String 'local copy
Private mvarMail_Message As String 'local copy
Public Property Let Mail_Message(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Message = 5
10 mvarMail_Message = vData
End PropertyPublic Property Get Mail_Message() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Mail_Message
10 Mail_Message = mvarMail_Message
End PropertyPublic Property Let Mail_Subject(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Mail_Subject = 5
10 mvarMail_Subject = vData
End PropertyPublic Property Get Mail_Subject() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print XThanks GOD the question got answer only. its like "Man who run in front of car get tired" "Man who run behind car get exhausted"
SOFTDEV If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]