Re: From my VB 2005 express Form. Want to send EMail
- From: Professor Yonce <ProfessorYonce@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 4 Dec 2006 07:03:01 -0800
I forgot to give you the listing.
Dim sb As StringBuilder
Dim theMessage As DataObject
'Dim objSB As New Text.StringBuilder
sb.Append(Form4Bio1.TextBox5.Text)
'If Form4Bio1.ListBox1.ItemsSelected.Count > 0 Then
If ListBox2.Items.Count > 0 Then
For Each ListItem As Object In ListBox2.SelectedItems
sb.Append(", ")
sb.Append(ListItem.ToString)
Next
End If
'theMessage. = sb.ToString
theMessage.body = sb.ToString
sb = Nothing
Form4Bio1.TextBox5.Text = Form4Bio1.TextBox5.Text & vbCrLf
'You could append a carriage-return linefeed between
'the items if you wanted to. Just replace the "," with
ControlChars.CrLf.
'Robin S.
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and Developer.
"Professor Yonce" wrote:
Hi RobinS I tried several things. I have a ListBox on the local form. I.
switched to it.
Her is my current code listing. I was able to get rid of all squiggly lines
except one.
It was theMessage saying it had not been defined so I put a Dim statement in.
But I must have it representing a wrong type cause I still get the one
squiggle line.
Either on theMessage or the Dim. Thanks. If you see my problem please let
me know. Right now, My squiggly line says the theMessage.Body is not a member
of the dataObject.
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and Developer.
"Professor Yonce" wrote:
Thank you RobinS. I tried your suggestions but can't get it to work yet.
I was getting a squiggly line below the StringBuilder word until I placed
another
Imports above .. Imports.System.Text Then the next squiggly line
showed up
under If Form4Bio1.ListBox3 I can't get rid of it yet. I have one more
squiggly line underneath theMessage I am still trying but don't see the
problem yet. thanks.
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and Developer.
"RobinS" wrote:
You have to use the selected item(s) in the item list. You're trying to
concatenate a Listbox.ObjectCollection to a string.
(And although + works, in VB most people use & so there's no
doubt about what it's doing.)
I think you should check and make sure they have selected items
before using the SelectedItem. I would try the following, which should
work whether they can select 1 item or many.
I'd use a stringbuilder to build the string, for efficiency.
Dim sb as StringBuilder
sb.Append Form4Bio1.TextBox5.Text
If Form4Bio1.Listbox1.ItemsSelected.Count > 0 Then
For Each ListItem as Object in Form4Bio1.ListBox1.SelectedItems
sb.Append ", "
sb.Append ListItem.ToString
Next
End If
theMessage.Body = sb.ToString
sb = Nothing
You could append a carriage-return linefeed between
the items if you wanted to. Just replace the "," with ControlChars.CrLf.
Robin S.
------------------------------------------
"Professor Yonce" <ProfessorYonce@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:FA3293B1-0807-45D2-87F0-FE7642A2F6A8@xxxxxxxxxxxxxxxx
Yes RobinS.. It worked. Thank You, Thank You.
I put the Imports line above the Public Class statement just like you
said.
I sent three e-mails as planned and Its the very first time I saw that
program
work as I planned. Wow! I never knew that before. It Build fine. No
errors.
I just saw one little problem I am trying to send the contents of the
TextBox.Text.
It went okay but I also wanted to add one more ListBox.Items to send also.
The + between the two did not work. How can I add the TextBox.Text plus
the
ListBox.Items to go in the e-mail? Thanks.
--
Professor Yonce, Retired commercial pilot. Also retired college department
Director and Professor. Presently a Communications Consultant and
Developer.
"RobinS" wrote:
The imports have to be above the Public Class statement.
Does that help?
Robin S.
---------------------
"Professor Yonce" <ProfessorYonce@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:AFF7C33F-42D4-4682-90E4-271315B8E27C@xxxxxxxxxxxxxxxx
I have made form for E-Mail. I have entered code but the Import system
does
not work. It has squiggly line underneath it showing it is not
communicating.
It Will not build.
Public Class Form3Bio1
System.Net.Mail.SmtpClient
Imports System.Net.Mail ' This line before ' does not work.
I have the rest of code to try if and when I am able to get System
working.
' I XXX out certain entrys below just for this publication.
Dim emailSender As SmtpClient
Dim theMessage As MailMessage
Dim SHost As String = ("smtp.XXXXX.com")
Dim Passwd As String = ("Harold45")
Dim Recv As String = ("Inssur@xxxxxxxxxx")
Dim Sndr As String = ("Harold@xxxxxx")
Dim Body As String = (Form4Bio1.TextBox5.Text) +
(Form4Bio1.ListBox1.Items)
emailSender = New System.Net.Mail.SmtpClient( _
SHost)
theMessage = New MailMessage
theMessage.From = New MailAddress(Sndr)
theMessage.To.Add(Recv)
theMessage.Subject = (Form4Bio1.TextBox4.Text)
theMessage.password = (Passwd)
theMessage.Body = (Form4Bio1.TextBox5.Text) +
(Form4Bio1.ListBox1.Items)
I have tried Importing the System.Net.Mail but can't find it. I have
.Net
2.0 installed.
My form system just does not allow System nor recognize the System.Net
Thanks for your kind help in advance. I do not know how I can get my
code
to
recognize Imports.System.Net.Mail.
--
Professor Yonce, Retired commercial pilot. Also retired college
department
Director and Professor. Presently a Communications Consultant and
Developer.
Was this post helpful to you?
--
Professor Yonce, Retired commercial pilot. Also retired college
department
Director and Professor. Presently a Communications Consultant and
Developer.
- Follow-Ups:
- Re: From my VB 2005 express Form. Want to send EMail
- From: RobinS
- Re: From my VB 2005 express Form. Want to send EMail
- References:
- Re: From my VB 2005 express Form. Want to send EMail
- From: RobinS
- Re: From my VB 2005 express Form. Want to send EMail
- From: Professor Yonce
- Re: From my VB 2005 express Form. Want to send EMail
- From: RobinS
- Re: From my VB 2005 express Form. Want to send EMail
- From: Professor Yonce
- Re: From my VB 2005 express Form. Want to send EMail
- From: Professor Yonce
- Re: From my VB 2005 express Form. Want to send EMail
- Prev by Date: Re: From my VB 2005 express Form. Want to send EMail
- Next by Date: Changing DisplayNames of my properties using PropertyGrid component, how ??
- Previous by thread: Re: From my VB 2005 express Form. Want to send EMail
- Next by thread: Re: From my VB 2005 express Form. Want to send EMail
- Index(es):
Relevant Pages
|
Loading