Link to home
Start Free TrialLog in
Avatar of backoffice
backofficeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Is this this programming correect for emailing?

Set oRS = Nothing      

            MailText = MailText & "<br><br>This email was sent as a system test .<br>"
            MailText = MailText & "Please contact REB for further details, or to be removed from the email list<br>"

            MailText = MailText & "</body></html>"
            If Not(MailTo = "")Then
                  Set EmailAlert = CreateObject("Outlook.Application")
                  Set EmailNameSpace = EmailAlert.GetNameSpace("mapiprofilename")
                  Set MailIitem = EmailAlert.CreateItem(0)
                        'MailItem.Recipients.Add MailTo
                        MailItem.Recipients.Add "gps@****.com"
                        MailItem.Subject = "PPCMS"
                        MailItem.HTMLBody = MailText
                        MailItem.Send
                  EmailNameSpace.Logoff
            End If
            MailTo = ""
            MailText = ""

      Next

Is this the correct scripting for using a mapi profile on a sql server? - it seems to run fine but doesnt seem to send any email!!

any help would be greatfully received..

Grant.
Avatar of Preece
Preece
Flag of United States of America image

-  There was a time when I worked on a vb6 app that had a send mail feature.  We used sql server as you are, but we also had to have Outlook installed on the sql server and configured to accept requests from sql svr.  We did have issues where the pending "sent" emails would queue up in Outlook and Outlook would not send them right away.  We would need to manually go in and send them....

-  Also, it seems that you may need to provide more complete html in your MailText.  This:

          MailText = MailText & "<br><br>This email was sent as a system test .<br>"
          MailText = MailText & "Please contact REB for further details, or to be removed from the email list<br>"

          MailText = MailText & "</body></html>"

may need to look more like:

          MailText = MailText & "<html><head></head><body>"
          MailText = MailText & "<br><br>This email was sent as a system test .<br>"
          MailText = MailText & "Please contact REB for further details, or to be removed from the email list<br>"

          MailText = MailText & "</body></html>"

Preece
Avatar of backoffice

ASKER

I have got outlook installed on the server. and if i do a test email from outlook itr works fine... BUT it does not seem to accept email rom sql server... what settigs do i have to change to allow outlook to accept email from sqlserver?
What versions of:

OS:
SQL Server:
Outlook:

Preece
OS win 2000
SQL 2000 + sp3a
Outlook 2000

when i test sql mail i get the following error:

error 18025 xp_test_mapi_profile failed with mail error 0x80040111

i have checked the mapi name and it is correct and i have sent a test email from outlook to myself..

When i type in the name of the profile i get the messaage that it isnt found on this computer BUT i assure you the profile is there and it is the correct name...

any suggestions..?
ASKER CERTIFIED SOLUTION
Avatar of Preece
Preece
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial