jjjamie Posted November 13, 2002 Posted November 13, 2002 I wonder if anyone can help me. I am trying to send email from a windows form application and I can't work out how to send attachments. How does everyone else do it? I'm comunicating directly with the SMTP server. Is there an easier way? Quote
*Experts* Bucky Posted November 13, 2002 *Experts* Posted November 13, 2002 (edited) This snippet in the Code Library shows how to accomplish the feat in VB6. If you can understand the concept and how it works, you should be able to apply it to VB.NET. [edit]My "b", use divil's idea instead[/edit] Edited November 13, 2002 by Bucky Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* divil Posted November 13, 2002 *Gurus* Posted November 13, 2002 myMailMessage.Attactments.Add(attachment) Where attachment is an instance of a MailAttachment class. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
jjjamie Posted November 15, 2002 Author Posted November 15, 2002 I am getting lots of upgrade warnings and errors when upgrading this code to .NET. Has anyone managed to upgrade this code successfully? Quote
*Gurus* divil Posted November 15, 2002 *Gurus* Posted November 15, 2002 That would be a Bad Idea. Use the .net way, with the classes under System.Net.Mail instead. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
jjjamie Posted November 15, 2002 Author Posted November 15, 2002 This program is not for the net, it's for a Windows form. I can't that namespace. (System.Net.Mail) Quote
*Experts* Bucky Posted November 15, 2002 *Experts* Posted November 15, 2002 (edited) That doesn't matter. The Net namespace has nothing to do with Web applications. The Net namespace provides any application with the ability to exchange data online, through several means (sockets, WebClient, etc.) Just add Imports System.Web.Mail at the top of your code and you're good to go (or you can type it minally throughout your code, it doesn't matter). [edit]Ah-ha, System.Web.Mail... gotcha! :)[/edit] Edited November 15, 2002 by Bucky Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* divil Posted November 15, 2002 *Gurus* Posted November 15, 2002 When I said System.Net.Mail what I really meant was System.Web.Mail. Even so, typing "SMTP" in to the help search box takes you straight there, so nil points for research! Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leeus Posted April 24, 2003 Posted April 24, 2003 Sub mailsender(ByVal mailto As String, ByVal msgbody As String, ByVal msgsubj As String, ByVal mailfrom As String, Optional ByVal attachment As String = "") Try Dim Message As New System.Web.Mail.MailMessage() Dim attachmentenc As System.Web.Mail.MailAttachment() Message.To = mailto Message.From = mailfrom Message.Body = msgbody Message.Subject = msgsubj Message.BodyFormat = Web.Mail.MailFormat.Html If attachment <> "" Then Message.Attachments.Add(attachment) End If System.Web.Mail.SmtpMail.SmtpServer = "62.105.167.3" System.Web.Mail.SmtpMail.Send(Message) Message = Nothing Catch MsgBox("Error Sending Mail") End Try end sub I cannot to save my life find out how to make the attachment thing work!!!! Please can someone put me right! Quote
Cassio Posted April 25, 2003 Posted April 25, 2003 You are not addind the MailAttachment object (attachmentenc) , you're addind a string in this line: Message.Attachments.Add(attachment) Quote Stream of Consciousness (My blog)
Winston Posted April 27, 2003 Posted April 27, 2003 hey that seems like the code i need im gonna use it if u dont mind Leeus, and can i ask do u just call that subroutine and it will send the email?... and two last quesys im a n00b wat do u have to specify in the System.Web.Mail.SmtpMail.SmtpServer = "62.105.167.3" System.Web.Mail.SmtpMail.Send(Message) Message = Nothing i dont get that Quote
Winston Posted April 27, 2003 Posted April 27, 2003 ok i get it now but for the smtpserver address ok i mean i have an smtp mail account setup on my system throuhg OE but wat if sum1 doesn have that setup what will they do?... say they were just a normal hotmail user Quote
Leeus Posted April 27, 2003 Posted April 27, 2003 You have to specify your outgoing mail server, just copy yuor settings from Outlook really, bear in mind it needs to be open for relay from your ip, i.e. the server I specified will not work for you! Quote
Winston Posted April 28, 2003 Posted April 28, 2003 what do u mean it needs to be opened in relay from your ip? i used my isp smtp server and made just a dummy app and let users test it on other isps it all worked i removed my emailaccount from OE and it worked u wanna try it out on urs here's the SMTP mail-hub.bigpond.net.au if i can find any other ones that are same as these im set i was wondering is it possible to make a little app that runs as a service which makes ur PC acts like the SMTP.. and using your default IP Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.