Solved

Forward messages to an internet address

Posted on 2000-05-02
16
302 Views
Last Modified: 2013-12-18
I would like to have a agent that forwards all my e-mail messages to my pop account.  When I create an agent using simple actions I must provide a new subject.  In addition all the messages in my pop account appear to be from me.  Is there a script/agent that will forward mail but keep the original sender and subject.
0
Comment
Question by:jason_turner
  • 7
  • 6
  • 3
16 Comments
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
you can go to your person document in the Public Address Book, or ask your admin to do so, go to the field 'Forwarding Address' and put your other email address, then all your messages would go to that address but a copy will NOT be stored in your Notes mail file.

-Gus
0
 
LVL 3

Expert Comment

by:Simon_Hendry
Comment Utility
I just answered a question

http://www.experts-exchange.com/jsp/qShow.jsp?ta=lotusnotes&qid=10337741

Here is a version for you..

 Dim Sess As New NotesSession
 Dim CurrentDoc As NotesDocument
 Dim MemoDoc As NotesDocument
 Dim ThisDB As NotesDatabase
 Dim Coll As NotesDocumentCollection
 Dim Body As NotesRichTextItem
 Dim i As Integer

 Dim Recp(1 to 1) As String

 Recp(1) = "YourPopAccount@Popserver.comn"

  Set ThisDB =  Sess.CurrentDatabase
                           
   ' Get all of the newly recieved documents
                           
      Set Coll = ThisDb.UnprocessedDocuments
                           
          For i = 1 To Coll.Count
                                 
              Set CurrentDoc = Coll.getnthdocument(i)
                                 
                Set MemoDoc = New NotesDocument(ThisDB)
                Set Body = MemoDoc.CreateRichTextItem("Body")
                 Call Body.AppendText("----------- Originally Sent By " + CurrentDoc.From(0) + " ----------------")
                   Call Body.AddNewLine(2)
                   Call CurrentDoc.Rendertortitem(Body)
                   MemoDoc.Form="Memo"
                   MemoDoc.Subject = CurrentDoc.Subject(0)
                   Call  MemoDoc.Send(False,Recp)
                   Call Sess.UpdateProcessedDoc(CurrentDoc)
                                 
            Next i

The message still comes from you but at least it would tell you who it came from... ( Message Spoofing is not possible in notes.. for good reason!!)

If you don't want to store your mail in your notes mail box and are happy just to forward it to your POP account go with gus's comment.
0
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
Just a note that u can set the 'from' field by writing the mail directly to the mail.box, or if using R5, set the 'principle' field to any value want.

-Gus
0
 
LVL 3

Expert Comment

by:Simon_Hendry
Comment Utility
its actually the PRINCIPAL Field
0
 
LVL 3

Expert Comment

by:Simon_Hendry
Comment Utility
I like the idea of writing to the mail.box , I had never thought of this !!
0
 
LVL 6

Expert Comment

by:ghassan99
Comment Utility
sorry a typo :-)

-Gus
0
 
LVL 3

Expert Comment

by:Simon_Hendry
Comment Utility
I gave the principal thing a go but the send method set the principal and the from fields ... But the mail.box thing worked brilliantly so here is the code update ... This does exactly what jason wants ( and for that matter I have a couple of uses for it !!)

Create a agent that is  triggered by "if new mail has arrived"

use this code and the mail will be stored in your Lotus Mail file as well as forwarded to the address specified in the Recp(1) = "...." Line.

'Code begins

Dim Sess As New NotesSession
     Dim CurrentDoc As NotesDocument
     Dim MemoDoc As NotesDocument
     Dim ThisDB As NotesDatabase
     Dim Coll As NotesDocumentCollection
     Dim Body As NotesRichTextItem
     Dim i As Integer
     Dim MailBox As NotesDatabase
     
     Dim Recp(1 To 1) As String
     
     Recp(1) = "YourPop@popserver.com"
     
     Set ThisDB =  Sess.CurrentDatabase

' The Mail.box database on the users mail server ( server string empty for background agent )

     Set MailBox = New NotesDatabase("","mail.box")

      ' Get all of the newly recieved documents
     
     Set Coll = ThisDb.UnprocessedDocuments
     
     For i = 1 To Coll.Count
         
          Set CurrentDoc = Coll.getnthdocument(i)
         
          Set MemoDoc = New NotesDocument(MailBox)
          Set Body = MemoDoc.CreateRichTextItem("Body")
          Call CurrentDoc.Rendertortitem(Body)
          MemoDoc.Subject = CurrentDoc.Subject(0)
          MemoDoc.From = CurrentDoc.From(0)
          MemoDoc.Recipients = Recp(1)
          Call  MemoDoc.Save(True,False)
          Call Sess.UpdateProcessedDoc(CurrentDoc)
         
     Next i
     
    ' Code Ends
0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
Simon, I added your code to the initialize portion of a new agent.  Although I am not sure what to do with the statement.

Set MailBox = New NotesDatabase("","mail.box")




0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:jason_turner
Comment Utility
Another question Simon.

Will this work when I am not actually in Lotus Notes; basically will this run on the server?


The purpose for this is is because I am forwarding my mail to a service that will let me listen to my e-mail messages while I am travelying and may not have access to my laptop.  Cool idea,

0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
After doing some digging as to what mail.box is, I did not see this on my desktop.  I am running a R5 client is this a problem?
0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
Simon,  this is what I was given by the service that reads my e-mail for me. ALthough it doesn't give me a error it doesn't work either


Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim dbDoc As NotesDocument
      
      Dim MailBoxdb As NotesDatabase
      Dim MailBoxdoc As NotesDocument
      Dim coll As NotesDocumentCollection
      
      Set db = session.CurrentDatabase
      Set coll = db.UnprocessedDocuments
      Set MailBoxdb = New NotesDatabase("notes-mail2/Tivoli Systems","mail\jturner.nsf")
' This section iterates through all the documents in this database and copies them to the Mail.Box database
' to be sent outbound over the internet
      For i = 1 To coll.count
            Set dbDoc = coll.GetnthDocument(i)
' Only send Memos, Replies, Replies w/ History and external mail, not Calendar entries
            If dbDoc.Form(0) = "Memo" Or dbDoc.Form(0) = "Reply" Or dbDoc.Form(0) = "Reply With History" Or Not dbDoc.HasItem("Form") Then
' Don't send messages reporting mail problems
                  If Instr(1, dbDoc.Subject(0) , "MAIL") + Instr(1,dbDoc.Subject(0) , "WARNING") = 0  Then
'  If dbDoc.DeliveredDate(0) > Today() Then
'  FROM LEE the above statement didn't make sense to me..... the DeliveredDate will never be GREATER than today... I'm going to assume it's a typo
                        If Not dbDoc.DeliveredDate(0) = "" Then
' FROM LEE The above if makes sure that the document is an INCOMING message and not a copy of an OUTGOING message
                              Dim item As NotesItem    ' Date check insert
                              Set item = dbDoc.GetFirstItem("DeliveredDate")
' Date check insert
                              place% = Instr(item.text, " ")                 '
' Date check insert
                              newDDate$ = Left$(item.text, place%-1)
' Date check insert
                              If newDDate$ = Date$ Then                
' Date check insert
' FROM LEE I put the above statements in because the date seemed important to the original developer.
' It is not strictly necessary for the agent to work.
' It does, however, restrict the agent to run ONLY on documents received that day.
' This could potentially cause a problem around midnight and the change over of the day.
' If the script were mine, I would not bother with it.
' If you remove all lines ( 6 ) that end with: "                 ' Date check insert", the script will work on all documents that are new.
                                    Set MailBoxdoc = MailBoxdb.CreateDocument
                                    Call dbDoc.CopyAllItems(MailBoxdoc, False)
                                    MailBoxdoc.Form = dbDoc.Form
                                    MailBoxdoc.Principal = dbDoc.From
' FROM LEE the "Principal" field is the key field for this agent to work.  Changing the "From" field isn't enough.
' The Recipients field must have the address of the CrossMedia inbox
                                    MailBoxdoc.Recipients = "jturner@myinbox.net"
                                    MailBoxdoc.SendTo = "jturner@myinbox.net"
                                    
                                    Call MailBoxdoc.Save( True, True )
                              End If                 ' Date check insert
                        End If
                  End If
            End If
            Call session.UpdateProcessedDoc( dbDoc )
      Next
End Sub
0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
I tried you first bit of code and it worked.  I will find out shortly if it will work once I log out and shut down.

Also in that first script is it possible to added the orginal sender to the subject of the message.
0
 
LVL 3

Accepted Solution

by:
Simon_Hendry earned 200 total points
Comment Utility
OK ...

Your code doesn't do what I was talking about... The Line

Set MailBox = New NotesDatabase("","mail.box")

Is in there because when the code is running as a background agent this is the Mail.box on your MAIL SERVER , this is the database the router uses to route mail... What you are doing is creating a new document in your mail file, This will not do the same thing!!!

What I am doing is waiting for a new document to arrive in your mail file and then taking a copy of it , re-wrting the SendTo and the Reciepents fields and saving it in the mail.box file, this will cause the mail router on the server to take that copy and reroute it to the new person specified in the RECIEPIENTS Field...

The PRINCIPAL FIELD is irrelevant for my this case as we are tricking the mail router into thinking it is delivering a new message...


Also notes in your code  the line

Set MailBoxdb = New NotesDatabase("notes-mail2/Tivoli Systems","mail\jturner.nsf")

will not work in a backgound agent because you have the server specified.. For background ( I mean scheduled run-on-server agents ) ... your need to use

Set MailBoxdb = New NotesDatabase("","mail\jturner.nsf")

But since this agent will be running in your mail file anyway you should just use

Set MailBoxdb = Session.CurrentDatabase

That way the code will be generic....

And yes this is a Server based agent , it runs on the server , so it doesn't matter if you are in Lotus Notes..

So here is a new version for you with the features you wanted... I don't think you need the date checking in there because you are running this on unproccessed documents of a "If new mail has arrived" triggered agent , therefore it will handle which documents have alraedy been sent..


         Dim Sess As New NotesSession
     Dim CurrentDoc As NotesDocument
     Dim MemoDoc As NotesDocument
     Dim ThisDB As NotesDatabase
     Dim Coll As NotesDocumentCollection
     Dim i As Integer
     Dim MailBox As NotesDatabase
     
     Dim Recp(1 To 1) As String
     
     Recp(1) = "YourPop@PopServer.com"
     
     Set ThisDB =  Sess.CurrentDatabase
     
                      ' The Mail.box database on the users mail server ( server string empty for background agent )
     
     Set MailBox = New NotesDatabase("","mail.box")
     
                            ' Get all of the newly recieved documents
     
     Set Coll = ThisDb.UnprocessedDocuments
     
     For i = 1 To Coll.Count
         
          Set CurrentDoc = Coll.getnthdocument(i)
          If CurrentDoc.Form(0) = "Memo" Or CurrentDoc.Form(0) = "Reply" Or CurrentDoc.Form(0) = "Reply With History" Or Not CurrentDoc.HasItem("Form") Then
                      ' Don't send messages reporting mail problems
          If Instr(1, CurrentDoc.Subject(0) , "MAIL") + Instr(1,CurrentDoc.Subject(0) , "WARNING") = 0  Then
          Set MemoDoc = New NotesDocument(MailBox)
          Call CurrentDoc.CopyAllItems(Memodoc, False)
          MemoDoc.Recipients = Recp(1)
          Call  MemoDoc.Save(True,False)
     End If
     Endif
     
          Call Sess.UpdateProcessedDoc(CurrentDoc)
         
     Next i
     
                          ' Code Ends
                 


Now If you want to test this from your workspace then set the agent to run from "action Menu" and set it to run on selected documents and change the line

     Set MailBox = New NotesDatabase("","mail.box")

to

     Set MailBox = New NotesDatabase("notes-mail2/Tivoli Systems","mail.box")

Save the agent and goto your inbox select a document and run the agent on it from the action menu....

Remember to set it back to

     Set MailBox = New NotesDatabase("","mail.box")

when you have finished and also set the agent back to triggered on "If new mail has arrived"


0
 
LVL 3

Expert Comment

by:Simon_Hendry
Comment Utility
In the code there is a typo the " Endif " should have a space in it
0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
Adjusted points from 100 to 200
0
 
LVL 1

Author Comment

by:jason_turner
Comment Utility
Simon Hendry,

You did a great job, here.  I hope we can work together again.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now