UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V < 1 2  (Go to first unread post)
   Reply to this topicStart new topic
> Ms Word Document As The Body Of An Email Created And Sent From Ms Access, Access 2016    
 
   
magicscreen
post Dec 2 2017, 04:11 PM
Post#21



Posts: 432
Joined: 18-November 07



Hi JonSmith,

I can use your code if I type in the email address of the person I am sending the email to.

But when using code to enter the email address I get the following message and the email stays in the Sent folder.


Task 'ArtSterling - Sending' reported error (0x800CCC0F) : 'The connection to the server was interrupted. If this problem continues, contact your server administrator or Internet service provider (ISP). The server responded: 550 5.1.0 ESMTP server not available AUP#O-1070'

CODE
Dim strBody As String
Dim strMessage As String

'With email with add specific stuff
            With olEmail.objEmail
                'Add the attachment
                .Attachments.Add strAttachmentPath
        
                
                If rsCurr!Delete_YN = False Then
                    
                
                    strBody = .HTMLBody
  
I AM NOT SURE IF I NEED THE NEXT TWO LINES BUT I COMMENTED THEM OUT
          
            '         strBody = Replace(strBody, "#DATE#", shtRibbon.Range("ribProcessDate"))
            '        .Subject = Replace(.Subject, "#DATE#", shtRibbon.Range("ribProcessDate"))
                     .Subject = "Fight Rising Healthcare Costs for your Employees"
            
                    'Display the email and fix the hmtl body
                    '.Display
                    .HTMLBody = strBody
                    .To = Trim(rsCurr!EmpEmail)
                    strMessage = .To
                    .Display
                    .Send
                  
                End If
Go to the top of the page
 
magicscreen
post Dec 2 2017, 04:39 PM
Post#22



Posts: 432
Joined: 18-November 07



Hi JonSmith,

If I type in the email address of the recipient it seems to work but if I enter the email address via code it sends the email to the Outlook Sent folder and I get an error message:

Task 'ArtSterling - Sending' reported error (0x800CCC0F) : 'The connection to the server was interrupted. If this problem continues, contact your server administrator or Internet service provider (ISP). The server responded: 550 5.1.0 ESMTP server not available AUP#O-1070'

I called my ISP and spoke to a Microsft tech and neither one knows what is causing this error.

This is some of my code:

CODE
Dim strBody As String
Dim strMessage As String
    
    Set dbCurr = CurrentDb
    Set rsCurr = dbCurr.OpenRecordset("Select * From tblEmailRecipients Where Recipient_YN = True Order By EmpFullName", dbOpenDynaset, dbSeeChanges)

    rsCurr.MoveLast
    rsCurr.MoveFirst

    While Not rsCurr.EOF
    
        If Nz(rsCurr!EmpEmail, "") <> "" Then
    
            'Create a new instance of the email class and set the template path and mail mode
            Set olEmail = New clsMailItemEvents
            olEmail.TemplatePath = Application.CurrentProject.Path & "\AmeriplanEmail.oft"
            olEmail.MailMode = 1 '1 For sending, 0 for edit template
        
            'With email with add specific stuff

            With olEmail.objEmail
                'Add the attachment
                .Attachments.Add strAttachmentPath
        
                'We save the html body here because when we .display the email the users default signature will be added.
                'We want to overule this so we replace the entire email body with this cached version which doesn't contain a sig.
                
                If rsCurr!Delete_YN = False Then
                    
                
                    strBody = .HTMLBody
            
I AM NOT SURE WHAT THE NEXT LINE IS FOR
                    'Replace the #NAME# part, used if you want any dynamic text in your body or subject

I AM NOT SURE IF I NEED THE FOLLOWING TWO LINES BUT I COMMENTED THEM OUT

            '        strBody = Replace(strBody, "#DATE#", shtRibbon.Range("ribProcessDate"))
            '        .Subject = Replace(.Subject, "#DATE#", shtRibbon.Range("ribProcessDate"))
                  
                     .Subject = "Fight Rising Healthcare Costs for your Employees"
            
                    'Display the email and fix the hmtl body
                    '.Display
                    .HTMLBody = strBody
                    .To = Trim(rsCurr!EmpEmail)
                    strMessage = .To
                    .Display
                    .Send

                 End If
                
            End With
       rsCurr.Movenext
   Wend
Go to the top of the page
 
2 Pages V < 1 2


Custom Search
RSSSearch   Top   Lo-Fi    10th December 2017 - 07:06 PM