I used to send email from VBA from an Excel Workbook. This worked correct. Now I have a new PC and tried to run the same code. And I get a permission error. I have checked, re-checked and double checked with my old PC, but I can't find any difference in settings. Not in Excel, nor in Outlook. Here is the mail I get when I try to send the mail (I just masked my email address with xxx@yyy,.nl).
Ntired everyting … nothing works …
Sender = "<Support> support@xxx.com"
Set objMail = objOl.CreateItem(0)
With objMail
.Sentonbehalfofname = Sender
.Subject = qrySubj
.HTMLBody = "<HTML><BODY>" & Text & "</BODY></HTML>"
.DeleteAfterSubmit = False
.To = Receiver
.Send
End With
On my old PC the mail is sent. On my new PC i get:
Uw bericht heeft enkele of alle geadresseerden niet bereikt.
Onderwerp: Dagelijkse rapportage mails
Verzonden: 13-8-2019 07:54
De volgende geadresseerde(n) zijn niet bereikt:
'xxx@yyy.nl' op 13-8-2019 07:54
Dit bericht is niet verzonden. U bent niet gemachtigd om het bericht namens de opgegeven gebruiker te verzenden.
Diagnostische gegevens voor beheerders:
Fout is [0x80070005-0x000004dc-0x00000524].
Exchange-antwoordheaders: request-id: 09cc6cb4-af3f-4613-ac6a-4bb18046bd0e X-ServerApplication: Exchange/15.20.2157.000 X-FEServer: AM0PR02CA0053 X-BEServer: AM0PR08MB4387 X-CalculatedBETarget: AM0PR08MB4387.eurprd08.prod.outlook.com X-RequestId: {F6762D9D-3507-476D-93ED-008D1A05C6A3}:108 X-ClientInfo: {17B3EEB2-65A2-4317-8132-4E5BAD253A55}:241960014 X-ElapsedTime: 1430 X-BackEndHttpStatus: 200 X-ResponseCode: 0 X-DiagInfo: AM0PR08MB4387 X-RequestType: Execute
Overzicht van externe bewerkingen:
0: ropWriteStream (45) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 0
1: ropRelease (1) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 0
2: ropSetProps (10) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 0
3: ropFlushRecipients (14) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 0
4: ropSetProps (10) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 0
5: ropTransportSend (74) Verwerkt(1) Voltooid(0)
Resultaat van externe bewerkingen: 0
Reactiecodes: 1244
Uitzonderingen bij reacties:
Index van externe bewerkingen: 5
Gekoppelde externe bewerkingen: ropTransportSend (74)
Microsoft.Exchange.Data.Storage.SendAsDeniedException: Can't transport send message. ---> Microsoft.Mapi.MapiExceptionSendAsDenied: MapiExceptionSendAsDenied: Unable to transport send message. (hr=0x80070005, ec=1244)
Diagnostic context:
Lid: 35250
Lid: 36674 dwParam: 0xA
Lid: 61250 dwParam: 0x0
Lid: 45378 dwParam: 0x2
Lid: 44866 dwParam: 0x46C
Lid: 36674 dwParam: 0xE
Lid: 61250 dwParam: 0x0
Lid: 45378 dwParam: 0x471
Lid: 44866 dwParam: 0x236
Lid: 55847 EMSMDBPOOL.EcPoolSessionDoRpc called [length=1049]
Lid: 43559 EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=148][latency=0]
Lid: 52176 ClientVersion: 15.20.2157.0
Lid: 50032 ServerVersion: 15.20.2157.6000
Lid: 35180
Lid: 23226 --- ROP Parse Start ---
Lid: 27962 ROP: ropSetProps [10]
Lid: 27962 ROP: ropFlushRecipients [14]
Lid: 31418 --- ROP Parse Done ---
Lid: 35250
Lid: 36674 dwParam: 0xA
Lid: 61250 dwParam: 0x0
Lid: 45378 dwParam: 0x2
Lid: 44866 dwParam: 0x46
Lid: 36674 dwParam: 0x4A
Lid: 61250 dwParam: 0x0
Lid: 45378 dwParam: 0x4B
Lid: 44866 dwParam: 0x0
Lid: 55847 EMSMDBPOOL.EcPoolSessionDoRpc called [length=172]
Lid: 43559 EMSMDBPOOL.EcPoolSessionDoRpc returned [ec=0x0][length=368][latency=0]
Lid: 52176 ClientVersion: 15.20.2157.0
Lid: 50032 ServerVersion: 15.20.2157.6000
Lid: 35180
Lid: 23226 --- ROP Parse Start ---
Lid: 27962 ROP: ropSetProps [10]
Lid: 27962 ROP: ropTransportSend [74]
Lid: 17082 ROP Error: 0x4DC
Lid: 44949
Lid: 21921 StoreEc: 0x4DC
Lid: 27962 ROP: ropExtendedError [250]
Lid: 1494 ---- Remote Context Beg ----
Lid: 38698
Lid: 37692
Lid: 37948
Lid: 33852 dwParam: 0x0 Msg: SMTP
Lid: 56248 StoreEc: 0x4DC
Lid: 40748 qdwParam: 0xB01000000000001
Lid: 57132 qdwParam: 0x0
Lid: 63016 dwParam: 0x4A
Lid: 39640 StoreEc: 0x4DC
Lid: 45434 Guid: 00011788-362d-8c85-0000-000000000000
Lid: 10786 dwParam: 0x0 Msg: 15.20.2157.000:AM0PR08MB4387:74f6b60d-ca04-46c4-80ff-8a31bf2a4ef7
Lid: 1750 ---- Remote Context End ----
Lid: 31418 --- ROP Parse Done ---
Lid: 22753
Lid: 21817 ROP Failure: 0x4DC
Lid: 59285
Lid: 46997 StoreEc: 0x4DC
at Microsoft.Mapi.MapiExceptionHelper.ThrowIfError(String message, Int32 hresult, IExInterface iUnknown, Exception innerException, MapiStore mapiStore)
at Microsoft.Mapi.MapiBase.ThrowIfError(String message, Int32 hr)
at Microsoft.Mapi.MapiMessage.TransportSendMessage(PropValue[]& propsToReturn)
at Microsoft.Exchange.Data.Storage.MapiAccessor.TransportSendMessage(Object mapiObject, ExTimeZone timezone, PropertyDefinition[]& propertyDefinitions, Object[]& propertyValues)
--- End of inner exception stack trace ---
at Microsoft.Exchange.Data.Storage.MapiAccessor.TransportSendMessage(Object mapiObject, ExTimeZone timezone, PropertyDefinition[]& propertyDefinitions, Object[]& propertyValues)
at Microsoft.Exchange.Data.Storage.CoreItem.TransportSend(PropertyDefinition[]& properties, Object[]& values)
at Microsoft.Exchange.RpcClientAccess.Handler.Message.TransportSend()
at Microsoft.Exchange.RpcClientAccess.Handler.RopHandler.<>c__DisplayClass154_0.b__0()
at Microsoft.Exchange.RpcClientAccess.Handler.ExceptionTranslator.TryExecuteCatchAndTranslateExceptions[TResult](Func1 protectedCode, Func
2 errorCodeExtractor, Boolean noThrow, TResult& result, Exception& exception, ErrorCode& errorCode)
Transportverzending is mislukt: foutopsomming(25), HResult(0x00000000), EC(1244). Transportverzending is mislukt: foutopsomming(22), HResult(0x00000000), EC(1244). Berichtverzending is mislukt: bericht-id(4), foutopsomming(13), HResult(0x80070005), EC(1244).
That means you (the current profile user) cannot send on behalf of the specified user. Try to comment out the line setting the SentoObehalfOfName
property and see if the message goes through.
User contributions licensed under CC BY-SA 3.0