Outlook 2007: Create a message rule that detects autoforwarded messages and handles them - email

I'm looking for kind of the opposite of creating a rule to auto-forward
emails. I want to create a rule that acts on RECEIVED auto-forwarded emails,
but not any that were manually forwarded or replied to by the same person.
E.g. Jim forwards me all emails with "blah" in the subject, and I want to
move those auto forwards to my "Jim's auto-forwards" folder, but if he
forwards me a message manually that says "blah" but he adds his own comments,
I want it to stay in my inbox.
Outlook seems to know that it is auto forwarded, as it shows up
as such when you view the email. Just above the "From" section but
just below the ribbon, it says something like:
"This message was AutoForwarded."
However I haven't found any option to create a rule filtering these.

Our exchange server (Outlook maybe?) adds the following headers when auto-forwarding:
Auto-Submitted: auto-generated
X-MS-Exchange-Generated-Message-Source: Mailbox Rules Agent
(Visible by opening an email and viewing the message "Properties" to see the headers) These appear to be what Outlook is using to detect that a message was AutoForwarded (or at least coincide)
And Outlook/Exchange 2013 has the filter option "with specified words in the message header"
I have used a rule that looks similar to the following to successfully move only "blah" subject messages autoforwarded from "Jim" to a specific folder:
Apply this rule after the message arrives
from 'jim#example.com'
and with 'blah' or 'blurg' in the subject
and with 'auto-generated' or 'Auto-Submitted' in the message heade
move it to the 'Jims auto-forwards' folder
And this has appeared to prevent any that he's manually forwarded from being processed by the same rule.

Our Exchange Server adds the following header for Auto Forwarded and Auto Replies
X-MS-Exchange-Inbox-Rules-Loop: abc#company.com
where abc#company.com is the email of the person auto forwarding the email.
I use MS Outlook 2010 in which i have setup a rule ->
From: abc#company.com
and with 'X-MS-Exchange-Inbox-Rules-Loop: abc.xyz#company.com'
or 'X-MS-Exchange-Inbox-Rules-Loop: abc.XYZ#company.com' in the message header
move it to the 'xyz' folder
i have checked abc.xyz#company.com as well as abc.XYZ#company.com in message header as in some auto Fwd/Re email header the Lastname of the sender was uppercase.
Note: as mentioned before this rule applies to all Auto Forwarded and Auto Replies (e.g Out of office/ vacation auto replies) from that person. Manual Fwd/RE emails are not filtered

I do not think rules can do this.
Try some VBA. untested
Edit 2013 02 26
Put the code in ThisOutlookSession http://www.slipstick.com/outlook-developer/how-to-use-outlooks-vba-editor/
Here are some references so you can debug if necessary.
NewMailEx: http://msdn.microsoft.com/en-us/library/office/bb147646(v=office.12).aspx
AutoForwarded Property: http://msdn.microsoft.com/en-us/library/office/ff867162.aspx
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryIDs
Dim objItem
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
varEntryIDs = Split(EntryIDCollection, ",")
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
'Debug.Print "NewMailEx " & objItem.Subject
If objItem.SenderName = "Jim Smith" Then
If objItem.AutoForwarded then
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
' Assumes destination folder is directly under the Inbox
Set myDestFolder = myInbox.Folders("Jim AutoForwarded")
objItem.Move myDestFolder
End If
End If
Next
Set objItem = Nothing
Set myDestFolder = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
End Sub

Related

Send an email from access via Lotus iNotes installed on intranet

I just need to be pointed in the right direction, on how
to send an email using VBA. I have Lotus as an email system which is embedded into our intranet system.
As a try, this code prepares an email and send it via Lotus (installed on pc) :
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim sender, recipient As String
'sender = Forms![LogIn]![TxtEmail]
If (Not IsNull(DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'"))) Then
recipient = DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'")
MsgBox "recipient *" & recipient & "*"
Else
MsgBox " recipient null"
End If
If Not (ns Is Nothing) Then
Call ns.InitializeUsingNotesUserName("CN=MyuserName/O=Cmpany", "password")
Set db = ns.GetDatabase("ServerName", "mail\MyuserName.nsf", False)
If (Not (db Is Nothing)) Then
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = recipient
doc.subject = "Email Subject"
Dim rt As NotesRichTextItem
Set rt = doc.CreateRichTextItem("Body")
rt.AppendText ("Body text")
doc.Send (False)
Set rt = Nothing
Set doc = Nothing
MsgBox "Message Sent."
Else
MsgBox "db Is Nothing"
End If
Set db = Nothing
Set ns = Nothing
Else
MsgBox "ns Is Nothing"
End If
My question here is how set this code to make the target Lotus the one on our intranet: my login is such "39398C#mycompany.com" and the application is accessed by "http://mail.mycompany.com/mail/username.nsf..."
Unfortunately this is not possible this way. This "embedded" Lotus Notes as you call it is a simple website. It is called "iNotes" and does not have any dlls installed on your client (unless you install the ActiveX control for IE, but that does not help anything with your problem).
For sending eMails via iNotes you need a complete new method and you need your Domino administrator to help you with it: You could either use a webservice to send your mail (this has to be enabled on the server) or you can use DIIOP (again: DIIOP- Task has to be loaded on server).
To at least compose an email, you could use the mailto: protocol, but you need to set iNotes to be your mailto- protocol- handler:
Open Internet Explorer browser and log into iNotes (http://mail.mycompany.com/mail/username.nsf). Please note that this option is not available at this time to Firefox browser users.
Click the "Preferences" button located in the top right corner.
Find "Default Mail Client" section on the "Basics" tab of the iNotes preferences.
Click the button "Make Default".
Using this approach you cannot send the mail directly but need the user to press "Send".
I am not sure what you mean by "I have Lotus as an email system which is embedded into our intranet system".
You need the Notes client installed locally to be able to use COM in your own code. Use the ID file (must be local in the Notes Data directory) for your corporate account amd point to the server on the network for your mailfile.
But you can't point your program to a iNotes instance on a web server, it has to be on a Domino server accessed with a Notes client.
What you could do is to create a new web application on the server, where you have an agent that will read HTTP POST data, create an email and send it out.
Then you simply make a HTTP post from your application.
Here are a couple of blog entries I wrote that might help you:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
http://blog.texasswede.com/parse-url-in-domino-agent/
You should probably change your code to send mail via SMTP instead of using the Notes API objects. Microsoft provides an object model called CDO that I think will help you. See the answer to theis question for details. You will just need the hostname or IP address information to connect to a Domino server in your infrastructure that supports inbound SMTP.
Not sure about it, because that code is pretty old as we know use Outlook and I haven't use it in a long while, but that might be some insight :
I seem to remember that if you add doc.From = ns.CommonUserName, this will choose your session automatically!
And the full code :
Dim session As Object
Dim db As Object
Dim doc As Object
Dim attachme As Object
Dim EmbedObj As Object
Dim attachment() As String
Dim i As Integer
Set session = CreateObject("notes.notessession")
Set db = session.GetDatabase("", "")
Call db.OPENMAIL
Set doc = db.CreateDocument
With doc
.Form = "Memo"
.sendto = MailDestinataire
'.copyto = MailDestinataire2
.Subject = Sujet
.Body = CorpsMessage
.From = session.CommonUserName
.posteddate = Now
.SaveMessageOnSend = True
End With

How to make an excel table that automatically sends email to someone on his birthday?

I need to write a formula that recognizes when someone's birthday is and trigger www.zapier.com.]
I have a birthday-recognition formula that creates a "send email" hyperlink, but I need it to be automatically sent (and delayed to 10am) non-interactively. I also did something in VBA but I only managed to write code that sends that message to 1 person.
Here's the working birthday-recognition formula. Client names are in column C8:C100, emails are in D8:D100, DOBs are in E8:E100 and the "send mail" hyperlinks are in F:100.
=IF(TEXT(E13;"d.m")=TEXT(TODAY();"d.m");HYPERLINK("mailto:"&D13&"? subject="&$D$2&"&body="&SUBSTITUTE(SUBSTITUTE($E$3;"$";C13);"#";$D$4);"pošalji čestitku");"")
"pošalji čestitku" = send mail (croatian language)
VBA code:
Private Sub CommandButton1_Click()
POŠALJIROĐENDANSKEČESTITKE
End Sub
Public Function POŠALJIROĐENDANSKEČESTITKE()
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
olMail.To = Cells.Range("D8:D1000")
olMail.subject = "Sretan rođendan"
olMail.Body = "Poštovani," & vbCrLf & vbCrLf & "Želimo Vam sretan rođendan"
& vbCrLf & vbCrLf & "Sve najbolje," & vbCrLf & vbCrLf & "svinaweb"
olMail.Send
End Function
This code just sends the message to one email when I click on the command button, but as I said I want it to be sent to every person that has a birthday today and to delay the sending of the emails to 10am instead of midnight.
I am using Excel 2013.
The Recipients property of the MailItem class returns a Recipients collection that represents all the recipients for the Outlook item.
The Recipients class provides the the Add method to create a new Recipient object and add it to the Recipients object. The Type property returns or sets the type of recipient. It can be one of the following OlMailRecipientType constants: olBCC, olCC, olOriginator, or olTo.
So, you can send the single email to all people. You just need to add them to the Recipients collection. Or, if you need to have individual message bodies, you can create separate email messages.
The DeferredDeliveryTime property of the MailItem class allows to set a Date indicating the date and time the mail message is to be delivered.

Send mails from Notes - when it is not used for mail

Ok, in these times when some people move from Lotus Notes to Office 365 I have come across a certain requirement...
An older workflow application sends mail to users. This has worked fine for ages. But now we have a new type of users. These users are just using Notes for a couple of old legacy applications like the one in question.
The error we get is:
File does not exist
And the code that generates it is pretty simple:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim rtitem As NotesRichtextItem
Dim doc2 As NotesDocument
Set db = session.CurrentDatabase
Set doc2 = New NotesDocument(db)
doc2.Form = "Memo"
doc2.Subject = "Test mail " & now
Set rtitem = New NotesRichTextItem (doc2, "Body" )
Call rtitem.AppendText("A simple test....")
Call rtitem.addnewline(2)
Call rtitem.AppendText("Link to complaint ")
Call doc2.Replaceitemvalue("sendto", "john#dalsgaard-data.dk")
doc2.Send( False )
It fails when running the last line....
So, the question really is: How can I code around the this issue?
I know there is no mail file for the user - and I would really prefer not to have to create one for the new users.
Thanks in advance!
/John
Error will appear when user triggering the code doesn't have a mail file specified in person document/location. One option would be to change code to save the new mail directly to server mail.box (assuming server is configured to route mails) or just send the email directly through SMTP using java.
Ok, I have done some trial & error testing on this....
Conclusion so far is that it works in this situation:
In the LOCAL location document (in names.nsf on the computer) you specify:
Mail server - as a server the user can reach
Mail "On Server"
An existing mail file - it can be ANY existing file on the server, it doesn't have to be a mail database.
Actually, a non-conclusive test indicates the mail database even doesn't have to exist (but the user with the setup for testing had to leave - so I couldn't confirm this tonight...)
Edit:
Further testing indicates that this may not be a problem if the user is NOT roaming. I need some further verification that this is actually the reason why I got it working (for one thing you cannot remove the mail file name again once added)... But thought I would add it here.

Why is a memo created and sent from a LotusScript agent converting rich text to plain and removing document links?

We have a Document Library set up to accept user administration requests from our managed school districts. I recently made some updates to the form used to enter requests and some minor changes to the agent used to notify our administrators of the new request. Since these changes, the notification emails, which were once being received in rich text with an embedded document link, are now coming in as plain text. I have reverted both the form and the agent to previous versions and email message remains plain text. The agent's code follows.
Option Public
Use "Variables"
Dim db As NotesDatabase
Sub Initialize
On Error Goto gotError
Set s = New NotesSession
Dim doc As NotesDocument
Dim kbaseDb As NotesDatabase
Dim kdoc As NotesDocument
Set db = s.CurrentDatabase
Set doc = s.DocumentContext
Dim fromName As NotesName
Dim commName As String
Set fromName = s.CreateName(doc.from(0))
commName = fromName.Common
Dim memo As New NotesDocument(db)
Dim body As NotesRichTextItem
memo.Form = "Memo"
memo.SendTo = techEmail
memo.Subject = doc.categories(0) + " admin request from " + districtName
If doc.priorityflag(0) = "Priority" Then
memo.Subject = doc.Categories(0) + " PRIORITY admin request from " + districtName
memo.DeliveryPriority = "H"
End If
Set body = memo.Createrichtextitem("Body")
Call body.AppendText("Please process this " + doc.action(0) + " request from " + commName + ".")
Call body.AddNewLine(2)
Call body.AppendText("Comment: " + doc.comment(0))
Call body.AddNewLine(1)
Call body.AddNewLine(1)
Call body.AddNewLine(1)
Call body.AppendText("Link to request ")
Call body.AppendDocLink( doc, "Link to request ")
Call memo.send(False)
Call doc.ReplaceItemValue("OwnerNotified", doc.Owner)
Call doc.Save(True, False)
Exit Sub
gotError:
Print "<b><FONT color=red>System Error (" + Str(Err) + "): " + Error
Exit Sub
End Sub
It seems like it's something to do with the signer of the agent- unless somehow your reversion to the original agent hasn't worked.
Here's a set of things I woudl check :
Identify the person who the agent is running as. It's usually the signer, or web user if it's a web agent and "Run as web user" is ticked on the agent properties.
Check their entry in the NAB. If they have their mail system NOT set to Notes, then the server's email sending settings must come into action when sending on their behalf - check the server document in the NAB, under MTAs .. Message Content field. I believe this tells the server how to send such emails.
If this is the issue, then fixes would be :
* Sign the agent with another Id who uses Notes Mail
* If you can't sign with another Id, set the email system of the signer to Notes Mail
Fingers crossed..
The fix was to change the "Message Content" setting for outbound MIME conversion. This is set to "Convert from Notes to plain text" by default and needed to be changed to "Convert from Notes to HTML".
Details are on this page in the InfoCenter:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.help.domino.admin.doc%2FDOC%2FH_SPECIFYING_MIME_CONVERSION_OPTIONS_OVER.html

Sent Outlook draft from other Computer

I got eMail account on Exchange Server and that situation. I start on my
Computer outlook (connected to this Email) run this code. The Email will created and saved in drafts.Thats working fine.
Than i take my notebook (connected to the same account) and try to sent it from the drafts. Get error wrong email address but it looks like correct address "test#test.com". If i delete this and type one more time the same address from my keyboard "test#test.com" it works.I got Windows 7 ,`Outlook 2013 with disabled Cached Exchange Mode.
_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)
mailItem.Recipients.Add("test#test.com")
mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()
Why should i retype the address? and how can i fix it?
_OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
Dim mailItem = CType(_OutlookApplication.CreateItem(OlItemType.olMailItem), MailItem)
Dim _TestRec As Recipient
_TestRec=mailItem.Recipients.Add("test#test.com")
_TestRec.AddressEntry.Address = "test#test.com"
mailItem.Body ="Text"
mailItem.Subject = "Subject"
mailItem.Save()
The problem is - mailItem.to setting only the Display Name. Had only to create a Recipient and set Recipient.AddressEntry.Address mailItem.Recipients.Add("test#test.com")