|
Public Function SendMailToDept(ByVal Fromm As String, ByVal Recipient As String, ByVal Cc As String, ByVal Subject As String, ByVal Body As String) As Boolean
'Sending Mail to multiple pepople coading by (Abhishek singh)abhishek_singh156@yahoo.com
Dim mailstatus As Boolean = False
Try
' Create a New blank MailMessage */
Dim mailMessage As MailMessage = New MailMessage()
mailMessage.From = Fromm
mailMessage.To = Recipient
mailMessage.Cc = Cc
'mailMessage.Bcc = txtBcc.Text;
mailMessage.Subject = Subject
mailMessage.Body = Body
mailMessage.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "144.1.14.3" (your server path)
SmtpMail.Send(mailMessage)
mailstatus = True
Catch ex As Exception
mailstatus = False
End Try
Return mailstatus
End Function
Public button_click()---------
Dim subjectmail, strreason as string
subjectmail = "Please chek this mail"
strreason="Error comes"
Dim strmail as string
strmail = SendMailToDept(abhisheksingh156@yahoo.com, abhishek_singh156@yahoo.com, abhisheksingh156@gmail.com, subjectmail, strreason)
End Sub
Thanks & Regards
Abhishek Singh
TATA STEEL(ITS)
Livelihood system
abhishek_singh156@yahoo.com
09709109796
|
|
|
|
|
I had that EXACT same problem a ton of times when we first started using the SMTP libraries... For me, it was only doing it on machines that had Norton or McAfee anti-virus installed. Both of those did real time scanning of e-mail as it was sent out. I'm not sure if it actually "hijacked" the connections or if it blocked those connections so that all mail was forced to route through it's proxy, but as soon as I turned off real time mail scanning, it worked fine every time.
Your code looks fine to me. Looks just like what I had when I was running into the same issues. I stripped mine all the way down to the bare minimums for testing.
|
|
|
|
|
One additional gotcha for .Net email:
The implementation caches the connection to a specific email server. If the email server bounces or a firewall drops the connection then the next email request will fail with a spurious error.
The solution is if an exception occurs, try to send it again, just once.
|
|
|
|
|
You could something like this:
' This is a action on pushing a button
On Error GoTo Err_Knop40_Click
Dim stDocName As String
Dim stDocOntvanger As String
Dim stDocFrom As String
Dim stDocCC As String
Dim stDocBcc As String
Dim stDocOnderwerp As String
Dim stDocText As String
Dim stDocAfzender As String
Dim Naam As String
Dim I As Integer
Dim strsql As String
Dim EMAIL
Dim rString As String * 255, sLen As Long, tString As String
'
tString = ""
sLen = GetUserName(rString, 255)
sLen = InStr(1, rString, Chr(0))
'
If sLen > 0 Then
'
tString = Left(rString, sLen - 1)
'
Else
'
tString = rString
'
End If
Naam = tString
stDocName = "Empty_Report"
stDocOntvanger = RTrim$(Me.EMAIL-address)
stDocOnderwerp = "Subject....... "
stDocText = "Hello " & RTrim$(Me.name) & " " & IIf(Left$(Me.subname, 1) = " ", "", RTrim$(Me.etc) & " ") & RTrim$(Me.othername) & ","
stDocText = stDocText & vbCrLf & vbCrLf
stDocText = stDocText & "With.........." & vbCrLf
stDocText = stDocText & "....Greetings" & vbCrLf & vbCrLf
stDocAfzender = "Sender......" & vbCrLf & vbCrLf
stDocAfzender = stDocAfzender & ".......Website:" & vbTab & "www........" & vbCrLf
ProviderIp = "192.168.0.0" ' whatever
mailtext = stDocText & stDocAfzender
Set EMAIL = CreateObject("cdo.message")
Foutje = 0
With EMAIL
stdDocFrom = RTrim(Name) & "@........"
EMAIL.from = RTrim(Name) & "@........"
EMAIL.To = stDocOntvanger
EMAIL.CC = ""
EMAIL.BCC = RTrim(BCCName) & "@......" 'For BCC purpose in a different folder
'
EMAIL.Subject = stDocOnderwerp
'
EMAIL.TextBody = mailtext
' Email.AddAttachment "C:\Scripts\Output.txt" ' If you would attachements to it
If MsgBox(mailtext, vbOKCancel, "To: " + stDocOntvanger) = vbCancel Then GoTo Afgebroken_Knop40_Click
I = 20
DoCmd.Hourglass True
EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ProviderIp
EMAIL.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
EMAIL.Configuration.Fields.Update
EMAIL.Send
DoCmd.Hourglass False
If Foutje = 0 Then
test = MsgBox("The mail is correct send in name of " & Name & " = " & RTrim(Name) & "@..........", vbInformation, vbOKOnly)
End If
End With
Exit_Knop40_Click:
Set EMAIL = Nothing
DoCmd.GoToRecord , , acNext
Exit Sub
Afgebroken_Knop40_Click:
test = MsgBox("The mail is not send in name of " & Name & " = " & RTrim(Name) & "@.........", vbOKOnly)
GoTo Exit_Knop40_Click
Err_Knop40_Click:
Foutje = Err.Number
Select Case Foutje
Case -2147220973
test = MsgBox("No connection with the mailserver." & vbCr & "Errornumber: -2147220973", vbCritical, vbOKOnly)
Case -2147220975
test = MsgBox("Wrong or silly answer from the mailserver." & vbCr & "Errornumber: -2147220975", vbCritical, vbOKOnly)
Case -2147220977
test = MsgBox("Mailaddress doesn't excist." & vbCr & "Errornumber: -2147220977", vbCritical, vbOKOnly)
Case 3075
test = MsgBox("SQL error occurred." & vbCr & "Errornumber: " & Str(Foutje), vbOKOnly)
Case Else
test = MsgBox("Unknown error occurred." & vbCr & "Errornumber: " & Str(Foutje), vbOKOnly)
End Select
Resume Next
.......
Maybe it was some help
|
|
|
|
|
Long time lurker, first time poster...
Ok, going to do a bit of a sum up here.
The issues you are seeing are most likey caused by a firewall on the user side, either on the machine or their ISP. A lot of ISP's won't allow residental users to send email out on port 25. Since you don't know what port is allowed, you'd have to have the user configure your app. Not a good idea. Or it could be a local firewall blocking the message because it doesn't know your app is allowed to send. Again, a configuration by your user would need to occur, and again, not a great idea, especially if you don't like support calls.
I'm with those that think it's a bad idea to use an SMTP transport to send an error message for an app outside of your network (we use smtp extensively inside our network), mainly because of security concerns. The username/password combo is used to authenticate a relay of the email message. This is bad to use outside of your network because someone could reverse engineer your code, find the username and password and start spamming through your mail server. If you insist on using SMTP, I would do a TRY CATCH to make sure the app can handle its own error and maybe set a counter to try more then once, then give up. You would also create a text file that you could have the user send to you as a backup.
If I was doing this, I'd probably look at creating a web service that the client app can send the message to and have it then emailed to me and/or inserted into a database. The issue there might be that the user has to approve the outbound request, but that shouldn't be too big of a deal. If you need a web service sample, let me know.
Cheers,
Mike
|
|
|
|
|
Meh, im really lost now. What to do? Keep trying and use the code others kindly provided in the thread, or drop bug reporting via email completely and try http/web service instead. I don't know anything about http servers and web services so yes, a sample would be nice.
Also, i don't feel like adding my username and password into my code as it can be retrieved from the compiled exe.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Forget the email.
You're (incorrectly) assuming that all your users have access to an unprotected smtp server, and that they have configured this server correctly.
This will not be true:
- in corporate environments, where exchange or lotus notes rule, and any good sysadmin will block access to the corporate smtp servers.
- if the user uses some form of webmail (gmail, hotmail, yahoo), and hasn't setup a local mail client.
You may want to setup an smtp server for these users, which you would run yourself, but I would strongly advise against it. You would be creating an open smtp relay that would attract spammers, and will get you blacklisted on smtp relays worldwide. Furthermore, most corporate environments and some ISP's block SMTP traffic.
Much better to report through some kind of webservice. If you're new to this, a good place to start reading is WCF (Windows Communication Foundation).
Note that you will need a fixed IP address at your side of the deal, and that you will have to configure routers, firewalls, and web servers. If you can't easily get a fixed IP address, you may be able to get away with some with some free dynamic DNS provider.
If this all sounds horrible complicated, get yourself a cheap asp.net provider, and host your error reporting code there.
|
|
|
|
|
What version of VS are you writing your code in? It will help me get you going in the right direction. Also, do you have access to a windows hosting provider or would you try and host this yourself?
Sorry if any of this is causing more confusion, but I think you'll be better off in the long run.
Mike
|
|
|
|
|
Im using Visual Studio 2010.
My host is using Linux systems to host its sites, so ASP and ASP.Net is a no-go.
Thanks for helping me, Mike.
Virtual Space Shuttle Astronaut
|
|
|
|
|
it never needs your username/password; it needs to log into the sender's email service, not yours.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
No i mean the username/password to access my http server.
Virtual Space Shuttle Astronaut
|
|
|
|
|
It does not necessarily require user name/password. All you need to know on the server is: who and when the report was sent and what does the report say.
You could implement some sort of hash to filter out spam traffic at http end.
If ASP/.Net is no go and you have PHP skills, you can rustle up a simple form to accept the above information on your website. *Then* you could send an email or insert into database or whatever from the webserver.
You could then submit this form from your desktop application code.
It does seem daunting at first for a bug reporting mechanism - but this is a much reliable approach than trying to send the email.
Hope this helps.
Shreekar
|
|
|
|
|
No i do not have PHP skills, but i figure it would'nt be that hard to make an online form for the bug reporting?
Im also waiting for Mike's example.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Sorry I was slow at getting back to you. Got sidetracked with my project and then it was all downhill from there.
I'm assuming you are still looking for some sort of solution to this. Are you interested in a method to create an execption report that can be emailed to you, or post to a web page?
Mike
|
|
|
|
|
That's ok.
Im looking for an online bug reporter form as an built-in reporter form in my application doesn't work very well. Users click the bug Reporter menuitem in my application at which point the online bug reporter form opens in their browser, from there, they can specify all the info and in addition upload an exception report. I have yet to find out how to produce such a report.
Thanks for your offer to help out.
Virtual Space Shuttle Astronaut
|
|
|
|
|
Has anyone here had experiance using multiple barcode scanners with a USB interface? One of our applications currently use USB to COM emulator and we need to get rid this...too many problems configuring them. So I'm goign to remove all the code for that portion and start fresh to implement USB into our application. We'll need up to two barcode scanners each using there own session of our application on the same PC. I read up on the Microsoft.PointOfService assembly and it seem the way to go, but I was wanting all the input I can get. The main issue is to have both sessions going and remember which scanner goes to which session of the application. Thanks for your help.
|
|
|
|
|
please don't remove any messages, what remains of the thread makes no sense any more.
(indeed, the widget just should not be available at all once a reply has been posted)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You may want to check out the HIDlibrary on SourceForge.net
I've used this library to build an application that integrates a MagTek USB magnetic swipe reader into a Point of Sales application. I did not require 2 USB swipe readers, but it should work.
Check it out ...
http://sourceforge.net/projects/hidlibrary/[^]
|
|
|
|
|
Seems the files are no longer available. Is it possible to get a copy from you?
Cheers,
Mike
|
|
|
|
|
|
|
I'm not sure I understand your problem; I assume you have peripherals (bar code scanners) with a serial interface, and are using USB-to-serial cables. If so, I don't see where the USBSerialEmulator comes in:
1.
a USB-to-serial cable comes with its driver, making the serial port available to Windows and all interested apps. You typically can have as many as you want, and choose the port name.
2.
bar code readers just emulate a keyboard, all they do is emit a string corresponding to the bar code, so a little code snippet based on SerialPort should be good.
3.
furthermore most bar code scanners can be taught to add a prefix and a postfix string of your choice, so you could e.g. prefix something that identifies the scanner, and postfix a newline combination.
If all the above applies, simply have one serial data receiver handle all the scanners, look for the prefix, and dispatch the actual data to the appropriate destination.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sorry....We have USB scanners and connect them as USB then use the USBSerialEmulator.
|
|
|
|
|
I may have to read up on this a bit.
Who created USBSerialEmulator? and what is the scanner's vendor, make and model?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Honeywell 3820...the emulator is Honeywell also. We have delt with Honeywell support on this and their response is "You cannot connect two scanners to the same PC using the USBSerialEmulator." We've tried, but it's just flaky. And when they switch the scanners around...its messy. We'd like plug and play with the ability to use both sections of the application at the same time on the same PC with two different scanners....that is why I think the original programmer tried the COM port.
|
|
|
|
|