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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Method 'to; Of Object '_mailtem' Failed, Access 2013    
 
   
Thor
post Jan 12 2018, 01:25 PM
Post#1



Posts: 477
Joined: 15-November 10



Hi all, long time no 'see'! notworthy.gif

Since i last visited this paradise we transitioned to Windows 10 and Office 2013 on a 64bit system. The issue is that some users are experiencing the Method 'To; of object '_Mailtem' failed error whilst others are not, despite the fact we are all on the same 'systems' as mentioned above. Below code is used and is referenced in the debug window for the error...what is going on? Has anyone experienced the same thing? What should i be looking for?

With objEmail
.TO = Me!SalesRep
.CC = Me!CCFIELD
.Subject = Me!SUBJECTLINE
.HTMLBody = strBody
.Attachments.Add (txtAttachment)

Thanks!

Go to the top of the page
 
cheekybuddha
post Jan 13 2018, 06:32 AM
Post#2


UtterAccess VIP
Posts: 9,372
Joined: 6-December 03
From: Telegraph Hill


Please post the whole code including the declarations

--------------------


Regards,

David Marten
Go to the top of the page
 
Thor
post Jan 13 2018, 11:59 AM
Post#3



Posts: 477
Joined: 15-November 10



Sure cheekybuddha, as previously mentioned some user are experiencing the error and cannot execute..for others it works just fine...i did not include the 'text' after strEmail = txtEmail for the sake of privacy...Thanks!

If IsNull(Me.txtAttachment) Then
CancelEvent = True
MsgBox "You need to select an attachment!"

Else


Dim strEmail, strBody As String
Dim objOutlook As Object
Dim objEmail As Object
Dim strAttachmentPath As String
Dim Signature As String

Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(0)

Signature = Environ("appdata") & "\Microsoft\Signatures\"
If Dir(Signature, vbDirectory) <> vbNullString Then
Signature = Signature & Dir$(Signature & "*.htm")
Else:
Signature = ""
End If
Signature = CreateObject("Scripting.FileSystemObject").GetFile(Signature).OpenAsTextStream(1, -2).ReadAll

strEmail = txtEmail

With objEmail
.TO = Me!SalesRep
.CC = Me!CCFIELD
.BCC = "fraudbase@monster.com"
.Subject = Me!SUBJECTLINE
.HTMLBody = strBody & "<br />" & "<IMG src=""C:\FraudBaseGlobal\image001.png"">" & Signature
Set objOutlookAttach = .Attachments.Add("C:\FraudBaseGlobal\EN - Sharing Proactive Outreach FAQs.doc")
Set objOutlookAttach = .Attachments.Add("C:\FraudBaseGlobal\EN - Resume license sharing outreach program.pptx")
Set objOutlookAttach = .Attachments.Add("C:\FraudBaseGlobal\Understanding the impacts - account and CV license sharing GBR.pdf")
.Attachments.Add (txtAttachment)





.Send

End With
Forms![CasesSingleView].[EMAILED] = "Yes"
DoCmd.OpenForm "LSEEMAILOthercfm"
CurrentDb.Execute "INSERT INTO dbo_EMAILLOG ([CASE_ID]) VALUES (" & CaseID & " );"
End If
End Sub
Go to the top of the page
 
cheekybuddha
post Jan 13 2018, 01:32 PM
Post#4


UtterAccess VIP
Posts: 9,372
Joined: 6-December 03
From: Telegraph Hill


Nothing obvious jumps out at me.

Is Me!SalesRep ever Null? If so, it would probably cause an error.

Otherwise, perhaps the eyes of others will spot what I haven't.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
cheekybuddha
post Jan 13 2018, 01:41 PM
Post#5


UtterAccess VIP
Posts: 9,372
Joined: 6-December 03
From: Telegraph Hill


Actually, perhaps you copied code from a duff source!

Look here
>> This property [TO] contains the display names only <<

Try adjusting your code:
CODE
' ...
  With objEmail
    .Recipients.Add Me!SalesRep
    With .Recipients.Add Me!CCFIELD
      .Type = 2    ' olCC
    End With
    With .Recipients.Add "fraudbase@monster.com"
      .Type = 3    ' olBCC
    End With
    .Subject = Me!SUBJECTLINE
    .HTMLBody = strBody & "<br />" & "<IMG src=""C:\FraudBaseGlobal\image001.png"">" & Signature
' ...


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
Thor
post Jan 13 2018, 02:21 PM
Post#6



Posts: 477
Joined: 15-November 10



Thanks cheekybuddha, i will try this out and let you know outcome, much appreciated! notworthy.gif
Go to the top of the page
 
Thor
post Yesterday, 02:29 PM
Post#7



Posts: 477
Joined: 15-November 10



Could the patches related to the 'Meltdown' and 'Spectra' issue affect Access VBA? How can i find out?

Just a thought out of the blue.....

Go to the top of the page
 
cheekybuddha
post Today, 06:09 AM
Post#8


UtterAccess VIP
Posts: 9,372
Joined: 6-December 03
From: Telegraph Hill


Interesting thought, but I doubt it.

More likely an Office update may be responsible if it worked before, but doesn't now.

Did the code changes help?

d

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th January 2018 - 06:48 AM