ebarro at afsweb.com
Thu Aug 18 21:54:34 CDT 2005
If you are trying to send via mail.optonline.com and it resolves to one of your machines on the internal network it won't work. Try using localhost which resolves to 127.0.0.1 (assuming that the mail server is your local machine) or the internal IP of the smtp server. -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby Sent: Thursday, August 18, 2005 6:58 PM To: VBA Subject: [dba-VB] Smtp mail from vb.net I'm trying to get .net to send email for me without going through Outlook. I found the following on the web: Imports System.Web.Mail Imports System.IO Module basMail 'TWO FUNCTIONS 'SAME EXCEPT FIRST TAKES A STRING FOR ATTACHMENT 'SECOND TAKES AN ARRAY LIST SO YOU CAN SEND MULTIPLE 'ATTACHMENTS 'FROM: Email address FRom 'TO: EMAIL address To 'Subject: Subject; Body: MessageText 'Optional CC, BCC: CC and bcc recipients 'SMTPSERVER: Optional, if not specified 'local machine is used 'AttachmentFile (first function: Optional, file name) 'AttachmentFiles (second function: Optional, list of 'attachments in form of an array list) Public Sub SendMailOneAttachment(ByVal From As String, _ ByVal sendTo As String, ByVal Subject As String, _ ByVal Body As String, _ Optional ByVal AttachmentFile As String = "", _ Optional ByVal CC As String = "", _ Optional ByVal BCC As String = "", _ Optional ByVal SMTPServer As String = "Mail.optonline.com") Dim myMessage As MailMessage Try myMessage = New MailMessage() With myMessage .To = sendTo .From = From .Subject = Subject .Body = Body .BodyFormat = MailFormat.Text 'CAN USER MAILFORMAT.HTML if you prefer If CC <> "" Then .Cc = CC If BCC <> "" Then .Bcc = "" If FileExists(AttachmentFile) Then _ .Attachments.Add(AttachmentFile) End With If SMTPServer <> "" Then _ SmtpMail.SmtpServer = SMTPServer SmtpMail.Send(myMessage) Catch myexp As Exception Throw myexp End Try End Sub When I call the function not passing in an smtp server, nothing obvious happens, no exception thrown. No email is delivered to my mail box though. If I pass in mySMTP server for outlook mail.optonline.com, it throws an error "system.web.httpexception - could not access cdo.message object". Any ideas? If not does anyopne have a drop in function for sending email that they can walk me through using?? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com ---------------------------------------------------------------- The information contained in this e-mail message and any file, document, previous e-mail message and/or attachment transmitted herewith is confidential and may be legally privileged. It is intended solely for the private use of the addressee and must not be disclosed to or used by anyone other than the addressee. If you receive this transmission by error, please immediately notify the sender by reply e-mail and destroy the original transmission and its attachments without reading or saving it in any manner. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of any of the information contained in or attached to this transmission is STRICTLY PROHIBITED. E-mail transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of email transmission. Users and employees of the e-mail system are expressly required not to make defamatory statements and not to infringe or authorize any infringement of copyright or any other legal right by email communications. Any such communication is contrary to company policy. The company will not accept any liability in respect of such communication.
More information about the dba-VB mailing list