I have done a lot of searching for snippets of code that will allow a user to send an e-mail. I can not find what I need nor I don't understand the code.
This is what I am looking to do:
To make things easy, I'll have a menu item that will say "Send for Technical Support". What I want to happen when the user clicks on that menu item is for his/her email client to come up. When that window shows, I will have my e-mail address in the "To" and the words "Technical Support" in the Subject.
All the user needs to do is to fill in the body of the text and send the e-mail. Control needs to return back to the VB application.
Can anyone help me out with a sample of code or the actual code I need to write.
However, if you want (as you asked) THEIR default email client to come up, a simple mailto: should suffice...done through a browser window, it usually invokes the default mail client. If you also want to add subject and stuff there's ways to do that, google "mailto options" and you should find more info :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
The instructions state "You also need a reference to the vbSendMail component in the Project References"
Question: Where do I find the references for vbSendMail and how do I put them in Project Reference area?
Reference becomes available after dll gets registered.
I thought someone who does this [apparently] since 2005 would know that.
Besides, zip file contains VBG files which stand for VBGroup so when it is loaded it will include multiple projects - one of them is "main" and one is dll.
Your main project will already have dll referenced so all you need to do is run it.
Okay: I added vbsendmail.dll to system32 directory and created the "References" entry.
Here's the code I copied and ran:
Code:
Private WithEvents poSendMail As vbSendMail.clsSendMail
Private Sub cmdSend_Click()
'Assumes you have a form with text boxes named as below
Set poSendMail = New vbSendMail.clsSendMail
poSendMail.SMTPHost = txtServer.Text
poSendMail.From = txtFrom.Text
poSendMail.FromDisplayName = txtFromName.Text
poSendMail.Recipient = txtTo.Text
poSendMail.RecipientDisplayName = txtToName.Text
poSendMail.ReplyToAddress = txtFrom.Text
poSendMail.Subject = txtSubject.Text
poSendMail.Attachment = txtFileName.Text 'attached file name
poSendMail.Message = txtMsg.Text
poSendMail.Send
Set poSendMail = Nothing
End Sub
Looking at this statement
Code:
poSendMail.SMTPHost = txtServer.Text
How do I find this value?
I am confused with this: For example: User1 might be using Outlook; User2 might be using Incredimail. The SMTP host will vary. So programmatically, how do I find the value?
While electronic mail servers and other mail transfer agents use SMTP to send and receive mail messages, user-level client mail applications typically only use SMTP for sending messages to a mail server for relaying...
...as I understand, the 'user' send the mail as a message to the SMTP server typed in the textbox and this SMTP server actually send the mail
look at the setting used by the current email client, it is generally related to the isp providing service,
vbsendmail does try to determine the default client without input from the user, sometimes works sometimes does not
if they have no smtp server available, the user would have to look at setting up an account for one, with a free service such as gmail or gmx
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
MAYBE, I am approaching this problem the WRONG WAY. Let me ask those of you with experience how you would handle this problem.
This is what I am trying to do:
I am writing an application that will be distributed to many users. If they run into any problems, I want to be notified. I have seen in many applications, usually in the "HELP" menu a link that might say "For Support...." or on a form, a Text box that would say "Enter your e-mail address". When the link is clicked your clients e-mail comes up and the user types in the body and sends the e-mail. Control returns back to the program.
Now, I DO NOT NEED TO DO IT THIS WAY but I am asking you professionals how I should handle the problem. Maybe this is more of a "design" question? If you wrote an an application and the user had a problem, how would you tell the user to contact you? Would you just give them an e-mail address or would you enhance that by bringing up the user's e-mail client OR would you do it a totally different way? If so, how?
transferring the error details to a webserver or developer by email
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
Try logging all errors to a text file and send it to the webserver or send it as an email to you..
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
for the user to contact you
you can use mailto: from shellexecute to fill an email in there default email client, to which they can add more information, then click send, this is probably the most useful method
to autosend details or log files, in background with no user interface i would use cdo.message, but vbsendmail would work as well, if unsure about the users stp server you could send all, from an account of your own from some free stmp server such as gmail or gmx
you can not use vbsendmail with gmail as gmail uses ssl, but there is code samples in this forum for using cdo.message to send through gmail
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
I have a problem with this too.
i've downloaded some source code, included the vbmaildll.
no success at all.
vbmaildll is the only program that show me exactly the reason of fail.
the reason is issue STARTTSL,
i looked in google, and i understand this is some format you need to include in the mail, but i couldn't figure out how.
maybe someone know something ?
EDIT: in general what i'm trying to do is, send a mail to valid email, from my pc, without login to some mail first.
is this possible ?
afaik
tsl is a secure socket, vbsendmail does not support secure sockets, you would need to modify the source code of the sendmail application
or use some alternative
like Secure Socket Layers (SSL) and Transport Security Layer (TSL), ...
send a mail to valid email, from my pc, without login to some mail first
you always have to login to some server, though it can be done in background
Last edited by westconn1; Jan 7th, 2010 at 05:27 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
@westconn1: I think setting the port to 465 will work... Not sure about this... I have faced the same problem, when a Gmail account is used in vbsendmail...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
i have no problem doing that in cdo, but have never had success in vbsendmail
cdo has a setting to use ssl
Last edited by westconn1; Jan 7th, 2010 at 05:40 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
but it fails with run time error
that the senduse doesn't set or somthing.
can you please post a working example
how to send simple text, (+ maybe one attach file)
to hotmail.com/gmail.com
the smtp is
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video) My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet Social Group:VBForums - Developers from India
usessl parameter (as set in the code for gmail) should work, gmail uses a secure server, change the server and port etc to suit whatever server you wish to use
if the user has a smtp email client already set up you can default the code to use that default server, but sendusing = 2 is required (use transport, for all external emails)
there is some constants used for sendusing (and other values), but i can not remember what they are
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
about 2 days ago, i could quite easy success with send to gmail.com
today i spent about 2 hours, trying to send , with a cleaner code, but couldn't successed.
after about 2 hours i looked into the mail, in the recieved mails that i did
2 days ago, and i got it.
your code has only one problem.
the "to" field has to be a valid email address.
i mean it can't be "me" as in your code, but it can be "[email protected]"
wow, at least i found it,
now other time i'll check the live.com server.
so please fix your code, so others won't spent hours like me
anyway thank you very much for your code, it was a really great help for me,
i was badly needed it.
i did assume anyone using the code would at least try sending to a valid email address
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Not sure if this would be of help but the mail retrieval project in my sig shows how to use Visual Basic 6.0 to send an email through Office Outlook.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
I have a problem with this too.
i've downloaded some source code, included the vbmaildll.
no success at all.
vbmaildll is the only program that show me exactly the reason of fail.
the reason is issue STARTTSL,
i looked in google, and i understand this is some format you need to include in the mail, but i couldn't figure out how.
maybe someone know something ?
EDIT: in general what i'm trying to do is, send a mail to valid email, from my pc, without login to some mail first.
is this possible ?
vbSendMail has WithEvents to trap errors:
Code:
Option Explicit
Private WithEvents poSendMail As vbSendMail.clsSendMail
Private Sub Command1_Click()
Call SendNotificationEmail("x", "Test", "test subject")
End Sub
Private Sub poSendMail_SendFailed(Explanation As String)
MsgBox ("Your attempt to send mail failed for the following reason(s): " & vbCrLf & Explanation)
End Sub
Private Sub SendNotificationEmail(ByVal pTo As String, _
ByVal pMessage As String, _
ByVal pSubject As String, _
Optional ByVal pCC As String = "")
10 On Error GoTo ErrorHandler
20 Set poSendMail = New vbSendMail.clsSendMail
30 poSendMail.SMTPHost = "Yourhost.com"
40 poSendMail.From = "[email protected]"
50 poSendMail.FromDisplayName = "DoNotReply.com"
60 poSendMail.Recipient = "[email protected]"
70 poSendMail.CcRecipient = "[email protected]"
80 poSendMail.Subject = pSubject
90 poSendMail.Message = pMessage
100 poSendMail.Send
110 Set poSendMail = Nothing
120 Exit Sub
ErrorHandler:
130 Err.Raise Err.Number, Err.Source & " [" & "SendEmailNotification Line: " & Erl & "]", Err.Description
End Sub
i did assume anyone using the code would at least try sending to a valid email address
you are right, but i'm very new to internet stuff,
so in the begining i didn't understand exactly what i'm doing.
now i understand, and i also understand, that probably, there is no way
to send a mail somewhere without login to a mail, first.
so now i learned 2 things, how to login to a mail, and how to send a mail.
thank you very much.
now i need similar thing, login to messenger account through the web page, with winsock.
sending request, waiting for respond and then sending the user name and password,
the only problem is that i don't exactly how to do that, yet.
Last edited by whatsup; Jan 13th, 2010 at 09:47 AM.
Since the original question was how to bring up the default mail client with the TO and SUBJECT fields filled in, I have attached a sample project using ShellExecute to accomplish just that.