System.Web.Mail Help Please...

Hello,

I've tried searching and searching, but I've had no real luck. I'm working on sending an email via an external SMTP server (I'm trying to use Gmail.com, could this be a problem ) and then send to another email, which also happens to be a Gmail.com address.

Now, before posting my code, I'd like to say, what I'm developing this for is basically a plugin for a program based on .NET 1.1, so I don't believe that System.Net.SmtpClient is an option, so therefore I'm stuck with System.Web.Mail.


Answer this question

System.Web.Mail Help Please...

  • mav888

    Ah, I got it working :)

    thanks for all the help

  • SBill

    TRy something like this

     

    'Sending a text email using a remote server 

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "Example CDO Message"
    objMessage.From = "TestUser100@.....com"
    objMessage.To = "TestUser100@.....com"
    objMessage.TextBody = "This is some sample message text."

    '----------------------------------------------------
    '==This section provides the configuration information for the remote SMTP server.
    '==Normally you will only change the server name or IP.
    '----------------------------------------------------
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    '----------------------------------------------------
    'Name or IP of Remote SMTP Server
    '----------------------------------------------------
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "xxxxxxxxxx"

    '----------------------------------------------------
    'Type of authentication, NONE, Basic (Base64 encoded), NTLM
    '----------------------------------------------------
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2

    '----------------------------------------------------
    'Your UserID on the SMTP server
    '----------------------------------------------------
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx"

    '----------------------------------------------------
    'Your password on the SMTP server
    '----------------------------------------------------
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxx"

    '----------------------------------------------------
    'Server port (typically 25)
    '----------------------------------------------------
    objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    objMessage.Configuration.Fields.Update


    objMessage.AddAttachment "F:\TMT\images\a_btn_tr_on.jpg"

    'Set objAttach = objMessage.Attachments.Add ' add the attachment
    'objAttach.Type = 1' CdoFileData
    'objAttach.Position = 0 ' render at first character of message
    'objAttach.Name = "F:\TMT\images\a_btn_tr_on.jpg"
    'objAttach.ReadFromFile "F:\TMT\images\a_btn_tr_on.jpg"

     

    '----------------------------------------------------
    '==End remote SMTP server configuration section==
    '----------------------------------------------------
    objMessage.Send
    set  objMessage = nothing

    Msgbox "Done"



  • Mark Bosley

    Could you please try a simple VBScript based program
    and then use the System.Web.Mail

    I will see if I can dig up a sample but may be there are
    some permission issues we should root out first.

    Let me know if you can find a sample



  • pgrever

    Could I see what the code looks like Thank you.
  • mcssnt

    I don't intend that you try this through C#
    Just try this through VBScript so that we can begin to troubleshoot



  • RockyIV

    I tried all the ones that would actually help me on there, and none seem to work.

    Any other suggestions

  • SecurityBreaker

    Dear Vikram & Dmcneil

    I am Also encountering the same problem as you both guys were,
    and you both have helped each other and find the solution to the problem,

    i am also in same boat as you are in, using cdo but getting error messages

    only when trying to connect to "smtp.gmail.com"

    Please help me, i need your help from both of you

    by the way i am web developer developing application related to net and now a days developing a big solution to send bulk mails through any system, while you have any smtp or not, database or not

    i will be requiring your help in that also.

    Thanks in Advance

    Your friend

    Vikram sachdeva


  • Maciej Swierzewski

    EDIT*

    I now try the other port used for SMTP setup at Gmail (587) and get this...

  • Professor Dave

    Try adding the SMTP server as follows:

    SmtpMail.SmtpServer.Insert( 0, "smtp.gmail.com")

    If that does not solve the issue then try other options from the list here:

    http://www.systemwebmail.com/faq/4.2.3.aspx

    Regards,

    Vikram



  • tblizzard

    Hmm, I've tried some classes from Codeproject.net, but none seem to be working, as I still get crash errors. I'm not sure if it's the SMTP server or not. GMail allows people to use third-party programs such as Outlook and Thunderbird to access it, and I'm putting my email information in the code exactly the way they have it when you setup with a program.

    I've tried messing with authentication, etc. and it doesn't seem to be working.

  • xzhutiger

    You may want to get a netmon capture to see what is really going on the wire.
    What I would do is to start with OUTLOOK express or somthing that works. get a capture. Then use CDO and then get another capture
    we can see what the differences are.

    It is possible that GMAIL Smtp server does not accept smtp connections from other email addresses so we should verify with a working sample first



  • DJeX

    Hmm, how would I go about doing this code in C#

  • franking

    Hi,

    Can u verify the SMTP to be working fine Can u try using smtp.gmail.com from Outlook Express and verify that its actually working Does it require authentication

    Regards,

    Vikram



  • ms_v

    Could you post a VBScript to use I can't seem to find one suited to the needs of testing.

  • System.Web.Mail Help Please...