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
> Outlook Script Troubles, Any Version    
 
   
NewbieCoder
post Dec 6 2019, 12:00 PM
Post#1



Posts: 1
Joined: 6-December 19



I have a script that the company has been using for a while and no issues. However, since we switched over to Outlook 2016, we have been experiencing some issues with it. When we run the script it works as it should and fills in the right information but when clicking on the send button, it bounces back to the email user's inbox saying "undelivered" and "This message could not be sent. You do not have the permission to send the message on behalf of the specified user." I have verified that the user has full access to that user mailbox. It's very frustrating for script to work fine in Outlook 2010 but not Outlook 2016.

Any help would be appreciated?

Sub ForwardA()

Dim objMail As Outlook.MailItem

Dim GetSMTPAddress As String, s As String, piece As String, i As Long, j As Long

Dim olkSnd As Outlook.AddressEntry, olkExu As Outlook.ExchangeUser
Dim olNS As Outlook.NameSpace
Set olNS = Application.GetNamespace("MAPI")
Set objITEM = GetCurrentItem()
Set olkSnd = objITEM.Sender
If olkSnd.AddressEntryUserType = olExchangeUserAddressEntry Then
Set olkExu = olkSnd.GetExchangeUser
GetSMTPAddress = olkExu.PrimarySmtpAddress
Else
GetSMTPAddress = objITEM.SenderEmailAddress
End If
Set olkSnd = Nothing
Set olkExu = Nothing
s = GetSMTPAddress
i = InStr(s, "@")
j = InStrRev(s, ".")
piece = UCase(Mid(s, i + 1, j - i - 1))
If piece = "--------" Then
piece = InputBox("----- - Enter New Company name")
End If

'MsgBox piece Set objMail = objITEM.Forward objMail.SentOnBehalfOfName = "orders@------.com" objMail.To = "" objMail.Subject = piece & ": CONFIRMATION RECEIPT OF " objMail.BCC = "" objMail.SendUsingAccount = olNS.Accounts.Item(1) objMail.Display Set objITEM = Nothing'
Set objMail = Nothing
MoveToCustomerPO`
Go to the top of the page
 
ADezii
post Dec 9 2019, 02:32 PM
Post#2



Posts: 2,732
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. I'm not sure if these are typos or not, but shouldn't the following lines of Code
    CODE
    objMail.SendUsingAccount = olNS.Accounts.Item(1) objMail.Display Set objITEM = Nothing'
    Set objMail = Nothing
    MoveToCustomerPO`
  2. be
    CODE
    objMail.SendUsingAccount = olNS.Accounts.Item(1) objMail.Display

    Set objITEM = Nothing
    Set objMail = Nothing

    MoveToCustomerPO
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    26th January 2020 - 04:16 PM