VBA Email from Access 2003 to Outlook 2007

  • Hi Vic

    I went in and tried again this morning on the XP machines. Low and behold it worked. I didn't change any code. I always find this sort of problem the most frustrating...

    I'm going to leave it to try - until I get some phonecalls. I'm not sure I need the Office 12 / 2007 converter as all the machines are running 2003 Access? All the other applications are 2007.

    Hi William

    Many thanks for your offer of sending me the code. That would be great. I'm happy to send my email address if that's how it is done? I also had the problem with SendObject. One minute it worked - the next it didn't. Which is too close for comfort to my current position.

    Many thanks

    Paul

  • Here is the original article that describes a method to send email from Access without referencing the Outlook library, it uses the Collaboration Data Objects CDO 1.21 library...

    SendObject method fails in Access 2000

    http://support.microsoft.com/kb/260819

  • Hi William

    That's great. I very much appreciate your help and support.

    Many thanks

    Paul

  • Try this to send email without having to automate outlook.

    Set iMsg = CreateObject("CDO.Message")

    Set iConf = CreateObject("CDO.Configuration")

    Set Flds = iConf.Fields

    strSchema = "http://schemas.microsoft.com/cdo/configuration/"

    Flds.Item(strSchema & "sendusing") = 2

    Flds.Item(strSchema & "smtpserver") = "smtp.yourdomain.com"

    Flds.Item(strSchema & "smtpserverport") = 465 'needed if using SSL

    Flds.Item(strSchema & "smtpauthenticate") = 1 'needed if using SSL

    Flds.Item(strSchema & "sendusername") = strAccount

    Flds.Item(strSchema & "sendpassword") = strPassword

    Flds.Item(strSchema & "smtpusessl") = 1

    Flds.Update

    With iMsg

    .To = strEmailAddress

    If strEmailCC <> "" Then

    .cc = strEmailCC

    End If

    .From = "youraccount@yourdomain.com"

    .Subject = strEmailSubject

    .HTMLBody = strEmailMessage

    .Sender = "youraccount@yourdomain.com"

    .Organization = "NHS"

    .ReplyTo = "youraccount@yourdomain.com"

    'possible loop here to add multiple attachments?

    .AddAttachment = strFilename

    Set .Configuration = iConf

    .send

    End With

    Set iMsg = Nothing

    Set iConf = Nothing

    Set Flds = Nothing

  • Hi Danbarua

    Many thanks for sending this. It looks very good. Email is working fine at the moment, but I'll give this a try and see if I can make it work.

    Best wishes

    Paul

Viewing 5 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic. Login to reply