how to send out email, if the smtp server needs authentication?
thanks
Printable View
how to send out email, if the smtp server needs authentication?
thanks
Set the Credentials property of your SMPTMail object to an object of type NetworkCredential.
Here is an example from another site:
VB Code:
'Create a new MailMessage object and specify the "From" and "To" addresses Dim Email As New System.Net.Mail.MailMessage("[email protected]", Email.Subject = "test subject" Email.Body = "this is a test" Dim mailClient As New System.Net.Mail.SmtpClient() 'This object stores the authentication values Dim basicAuthenticationInfo As New System.Net.NetworkCredential("username", "password") 'Put your own, or your ISPs, mail server name on this next line mailClient.Host = "Mail.RemoteMailServer.com" mailClient.UseDefaultCredentials = False mailClient.Credentials = basicAuthenticationInfo mailClient.Send(Email)
Is the System.Net.Mail.MailMessage available for .NET framework 1.1?? I've tried to do it with VS.NET 2003, it doesn't have System.Net.Mail.MailMessage
Use System.Web.Mail in .NET 1.x. I guess that Microsoft has now decided, quite rightly, that e-mail is actually a network thing and not a World Wide Web thing.
Also, in VS.NET 2003 The System.Web.Mail namespace can't be called from a regular VB.NET Windows Application without adding a reference to System.Web.
Bill
Thanx for the replies guys, i'm working on it ^^
thanks every1.the problem is: I'm using .NET 1.x, is there a way to use credential shown in the example? In .net, I can not use:
mailClient.UseDefaultCredentials = False
mailClient.Credentials = basicAuthenticationInfo
thanks
Things have changed for the better in .NET 2.0. I don't know all the differences in the mail classes but it's likely to be different and less powerful in the 1.x version.
Is the Visual Studio Express .NET 2.0? Do I have to uninstall VS 2003 to install VB Express 2005? On MS's site, they did not mention this. Any1 knows?
thanks.
No, you should be fine, but if you have a previous beta version of any VS 2005 product, you need to uninstall it first - I can attest first hand that ignoring that advice can cause you alot of pain.
Bill
Any1 else can confirm that VS 2003 Enterprise and VS Express 2005 can be installed on the same machine without problem? I just want to be cautious, since I have a project built by 2003 enterprise and do not want to be messed by VS Express 2005.Quote:
Originally Posted by conipto
thanks
Well, I can tell you I've had both running at the same time, and though I removed VB Express, I currently run VS 2005 Beta 2 and VS 2003 at the same time.. Quite often both at the SAME time, to copy and paste code and whatnot. I have had one tiny problem - VS 2005 Took over all my file type extensions, and when I double click them it tries to open them in 2005. That would be easily remedied by changing the file type associations though.
Also, For what it's worth, I mentioned that first hand I'd experienced problems with not uninstalling the beta versions.. My exact scenario was this: I had been using 2003 for some time, then installed the VB Express beta, SQL Server Express Beta, because I was curious as to what MS was going to be offering entry level developers. I then decided to check out the full Visual Studio, because I liked alot of the features in even the express edition (Better templates, and the "lining up tool" in the designer for controls especially) I ignored the advice of MS and just installed VS 2005 when my beta CD came in the mail. It completely killed my OS. The PC kept rebooting after 30 seconds of on time, and I was not cool with that. I tracked the problem back to SQL Server Express beta somehow conflicting with SQL Server 2005 beta. However, uninstalling the express beta for SQL Server, I was and am still able to use both VS 2003 and 2005 without a problem. The only conflict I ever had was with SQL server versions, and I'm sure by release they'll work that bug out.
Bill
thank you very much, really appreciate the help. I will try it.Quote:
Originally Posted by conipto
thanks again
I tried it on two machines. It seems it is ok for VS 2003 and VS Express 2005 to be installed on the same machine. I compiled 1 project and added some more features, seems ok.
Also, there are some posters about this at: http://forums.microsoft.com/MSDN/Sho...ID=24&SiteID=1
thanks for every1, especially 'conipto'. appreciate all the help.
How do you delimit multiple addresses using the 2005 mail object model.
VB Code:
Dim mc As New System.Net.Mail.MailAddressCollection mc.Add(str)
If I pass a semi-colon delimited list of email addresses (as per .NET 2003) as str, it throws an exception - invalid email address.
It works fine if I pass a single email address.
This question really should have been posted in a new thread as it really isn't connected to the original question.Quote:
Originally Posted by robertx
Given that it's a MailAddressCollection, I'd guess that you'd Add each address to it individually.
I realise that you can just "Split" the semi-colon delimited string and iterate through the resulting array and add each address one by one.
The name of the argument of the Add method of System.Net.Mail.MailAddressCollection is "addresses As String" (ie.plural) which gives the impression that you can pass multiple addresses in a single string in a similar way that you were able to with the .NET v1.1 mail object model.