1

I have a VBA programme that runs in Excel and creates a collection of about 20 draft Outlook email objects. Simple HTML with no attachments. The user is then given a choice:

  1. Send each one directly, using an instruction something like c_email(j).Send

  2. Display each ones directly, to allow the option of customisation/amendment, before the user presses the send button themselves. The command here is c_email(j).Display

My problem is that 1) generates a spam failure message (extract below), while 2) works fine -- even though the emails themselves are identical.

Any thoughts?? Weirdly, I have another routine that does something very similar (different type of message, to a different group of people) and this works fine in both modes.

>>>>>>>>

Diagnostic information for administrators:
Generating server: VE1PR10MB3919.EURPRD10.PROD.OUTLOOK.COM
info@judgefamily.org.uk
Remote server returned '550 5.7.520 Message blocked because it contains content identified as spam. AS(4810)'
Original message headers:
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Simon J
  • 11
  • 1

2 Answers2

0

Something in your code triggers your spam filter. Go with basics, the code below is as simple as it can get. Try to first run and display, to see that everything works as it should, then change to send and try again. If this works, then there's someting wrong with your code, otherwise your not allowed to send mail with vba i guess. If it works, make a new post where you show your code.

Sub sendMail()
'add ref: Microsoft Outlook 16.0 Object Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
On Error Resume Next
With OutMail
    .To = "" 'type your mail here
    .Subject = "Subject"
    .Body = "Body"
    '.Send
    .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Loveb
  • 278
  • 1
  • 9
  • 1
    _make a new post where you show your code._ ..... edit the original post to show your code. Edit button is below the tags. – Darren Bartrup-Cook Jun 30 '23 at 09:55
  • fyi. Although `On Error Resume Next` followed by `With OutMail` is an often seen structure it is inappropriate 100% of the time. Delete `On Error Resume Next`. If there is an error you may fix it or apply appropriate error handling. Note: In other circumstances, `On Error Resume Next` will be inapproporiate 99.9999% of the time. – niton Jul 01 '23 at 12:26
0

Problem solved.

I had a small error in the way the .HTMLbody string was built up in this routine (but not in the other similar routine). (I think the tags were in the wrong place). This generates a Spam error when the email is sent directly using the .send command; but I guess outlook adjusts the syntax when using the .display command and so it sends OK

Simon J
  • 11
  • 1