Results 1 to 10 of 10

Thread: [RESOLVED] Send Email

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    [RESOLVED] Send Email

    Guys.

    I am converting a vbscript over to vb 2005. When moving the code over below it seems vb 2005 does not like , on each of the new lines.

    Can someone please let me know what i should replace the , with?


    objEmail = CreateObject("CDO.Message")

    objEmail.From = "[email protected]"
    objEmail.To = "[email protected]"
    objEmail.Subject = "New User - " & strFirst & " " & strLast & " Elite Account Details "
    objEmail.Textbody = Join( Array( _
    "****Automatic email****," _
    , " "_
    , "Please note London IT have created a new user."_
    , " "_
    , "Name: " & strFirst & " " & strLast &" " _
    , " "_
    , "Initials: " & strUser & " "_
    , " "_
    , "Elite Password: " & objPassDlg.password & " "_
    , " "_
    , "Department: " & sDepartment & " "_
    , " "_
    , "Office Location: " & WithersOffice.Value & " "_
    , " "_
    , " "_
    , "Accounts could you please add this user to Elite please and do your Magic!"_
    , " "_
    , "Regards"_
    , " "_
    , "European IT Helpdesk"_
    , "Withers LLP"_
    , " "_
    , "+44 (0) 207 597 6440"_
    , "[email protected]"_
    , " "_
    , "****Please note this email was automatically generated from the IT User Creation Script****"_
    , " "_
    , "Please contact the European IT Helpdesk x6440 with any issues"_
    , " "_
    , "This Account has been created by: " & strLoggedonUser & ""_
    , " " ), vbCrLf )
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
    "IP ADDRESS HERE"
    objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Update()
    objEmail.Send()

    End If
    Last edited by cjwallace; Feb 18th, 2007 at 12:26 PM.

  2. #2
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Send Email

    Look at the System.Net.Mail namespace.

    Also, check out this link. http://www.systemnetmail.com/
    My.Settings.Signature = String.Empty

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Send Email

    Hi mate and thanks very much for the reply.

    Ok i have taken a look at the site you said and the bit of code i think i need to use is below. Now as you can see from my first post my email contains multiple lines in the body. Do you know how i can make the code below multiple lines?

    'create the mail message
    Dim mail As New MailMessage()

    'set the addresses
    mail.From = New MailAddress("[email protected]")
    mail.To.Add("[email protected]")

    'set the content
    mail.Subject = "This is an email"
    mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"
    mail.IsBodyHtml = True

    'send the message
    Dim smtp As New SmtpClient("127.0.0.1")
    smtp.Send(mail)



    Thanks again for any help you may give.

  4. #4
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: Send Email

    I've maked an mailscript a few days ago, check http://www.vbforums.com/showthread.php?t=452345
    Hope it's help!

    Maybe will <br> wil help!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Send Email

    Thanks for the reply.

    I had a look but i am still unable to work out how to make the body of the email on more than one line.

  6. #6
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Send Email

    You could try putting in an Environment Newline

    VB Code:
    1. smail.Body = "Hello there" & Environment.NewLine & "Will this be on a new line"


    Or perhaps using the <br> tags would work in html. If I remember it marks a new line. Same as putting things in <p>This is a paragraph</p> does.

    See if any of them work.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Send Email

    Thank you i will give this ago.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Send Email

    Oh just one more thing. How can i do it so that my code is not scrolling off the page? i have about 15 lines of my email and i would rather my code go down the page rather than accross.

    Also if i wanted two new line would i just use

    & Environment.NewLine & & Environment.NewLine &

    Many thanks
    Last edited by cjwallace; Feb 18th, 2007 at 09:39 AM.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Send Email

    Got it. i just need to use & Environment.NewLine & _

  10. #10
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Send Email

    Oh, that. I thought you were still referring to it going across in the actual email being sent.

    Well, glad you found everything. Resolve etc... if you are all done.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width