Hi,
I got this code for sending a lot of mails on behalf of a shared mailbox in Outlook (Office365)
It's the same code that runs for each mail but at some point it start sending mails from myself and not on behalf of the shared mailbox. Sometimes it send 100 mails before it happens other times it could be 150 times. Does anybody have a clue what is going on?
Hoping for some help from you experts
Best Regards
Claus
I got this code for sending a lot of mails on behalf of a shared mailbox in Outlook (Office365)
It's the same code that runs for each mail but at some point it start sending mails from myself and not on behalf of the shared mailbox. Sometimes it send 100 mails before it happens other times it could be 150 times. Does anybody have a clue what is going on?
Code:
Sub MAtekst(tekst1 As String, tekst2 As String, Mail As String, disp As String, header As String) Dim OutApp As Object, OutMail As Object
Dim wsSend As Worksheet, wsTemp As Worksheet
Dim StrBody1 As String, StrBody2 As String
Dim rowstemp As Integer
Dim rng As Range
Set wsSend = ThisWorkbook.Worksheets("Send")
Set wsTemp = Worksheets("Temp")
rowstemp = wsTemp.Cells(wsTemp.Rows.Count, "A").End(xlUp).row
StrBody1 = "****** style='font-family:calibri;font-size:11pt'>" & tekst1
StrBody2 = "****** style='font-family:calibri;font-size:11pt'>" & tekst2
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set rng = wsTemp.Range("A1:D" & rowstemp).SpecialCells(xlCellTypeVisible)
On Error Resume Next
With OutMail
.To = Mail
.Subject = header
.GetInspector.Activate
.HTMLBody = StrBody1 & RangetoHTML(rng) & StrBody2
.SentOnBehalfOfName = wsSend.Cells(1, 2)
.Send
End With
End If
On Error GoTo 0
End Select
Hoping for some help from you experts
Best Regards
Claus