dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Sending mail with script (excluding attachment from form) - lotus-notes-programmer

This is a discussion on Sending mail with script (excluding attachment from form) - lotus-notes-programmer ; I would be gratefull for some advice with the following script I am using to send mail, it works as far as sending the mail but it includes an attachement from the form in the e mail (which I don't ...


Home > Database Forum > Other Technologies > lotus-notes-programmer > Sending mail with script (excluding attachment from form)

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 11-03-2008, 06:31 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Sending mail with script (excluding attachment from form)

I would be gratefull for some advice with the following script I am
using to send mail, it works as far as sending the mail but it
includes an attachement from the form in the e mail (which I don't
want). Any ideas ?

Code;
Public Function Submit
Dim session As New NotesSession
Dim ws As New NotesUIworkspace
Dim Sender As String
Dim Recipient As String
Dim user As String
Dim verifier As Variant

Set uidoc=ws.CurrentDocument
Set doc=uidoc.document
User = session.CommonUserName
Recipient = uidoc.FieldGetText("Recipient")
Sender = uidoc.FieldGetText("txtname")

uidoc.Save
doc.Form = "Memo"
doc.Subject = "Corrective Action Request"
Set Body=New NotesRichTextItem(doc,"Body")
Call Body.AppendDocLink(doc,"Please Click this Link to open the
Document")

Select Case doc.txtStatus(0)

Case "Draft"
Call Body.AppendText(" CAR for action Please follow this document
link for details. Please accept or reject as appropriate ")
Call doc.Send (False, uidoc.FieldGetText("txtRecipient"))
uidoc.EditMode = True
Call Body.AppendText("**********This is a copy of a recent CAR for
your information*********")
Call doc.Send(False, uidoc.FieldGetText("txtCopyTo"))
Call uidoc.FieldSetText("txtstatus", "Submitted for Acceptance")
uiDoc.Save
Uidoc.Close

Case "Accepted - In Progress"

If user = Recipient Then
Call Body.AppendText(" CAR for validation")
Verifier = sbmtVerifiers(VerifierChosen)
'Call doc.Send (False, sbmtVerifiers(VerifierChosen))
'Call uidoc.FieldSetText("Verifier",Verifier)
Call doc.Send(False, Verifier)
Call uidoc.FieldSetText("txtstatus", "Submitted for Validation")

uiDoc.Save
Uidoc.Close
Else
Messagebox("Only the recipient can send documents for validation!")
Call uidoc.FieldSetText("saveoptions", "0")
uidoc.Close(True)
continue = False
End If

Case "Rejected"
If User = Sender Then
Call Body.AppendText(" CAR for action Please follow this document
link for details. Once Accepted please agree a CAR date for completion
")
Call doc.Send (False, uidoc.FieldGetText("txtRecipient"))
uidoc.EditMode = True
Call uidoc.FieldSetText("txtstatus", "Submitted for Acceptance")
uiDoc.Save
Messagebox("Thank you, the CAR has now been submitted")
Uidoc.Close
Else
Messagebox("Only the originator can send documents for action!")
Call uidoc.FieldSetText("saveoptions", "0")
uidoc.Close(True)
continue = False
End If

Case "Validation rejected"
If User = Recipient Then
Call Body.AppendText(" CAR for validation")

Call doc.Send (False, sbmtVerifiers(VerifierChosen))
uidoc.EditMode = True
Call uidoc.FieldSetText("txtstatus", "Submitted for Validation")
uiDoc.Save
Uidoc.Close
Else
Messagebox("Only the originator can send documents for
validation!")
Call uidoc.FieldSetText("saveoptions", "0")
uidoc.Close(True)
continue = False
End If
End Select
End Function

Reply With Quote
  #2  
Old 11-04-2008, 06:49 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sending mail with script (excluding attachment from form)

what is doc ??
Wher do you set it?
is it the same document opened in the workspace or another one you created?



mj ha scritto:
> I would be gratefull for some advice with the following script I am
> using to send mail, it works as far as sending the mail but it
> includes an attachement from the form in the e mail (which I don't
> want). Any ideas ?
>
> Code;
> Public Function Submit
> Dim session As New NotesSession
> Dim ws As New NotesUIworkspace
> Dim Sender As String
> Dim Recipient As String
> Dim user As String
> Dim verifier As Variant
>
> Set uidoc=ws.CurrentDocument
> Set doc=uidoc.document
> User = session.CommonUserName
> Recipient = uidoc.FieldGetText("Recipient")
> Sender = uidoc.FieldGetText("txtname")
>
> uidoc.Save
> doc.Form = "Memo"
> doc.Subject = "Corrective Action Request"
> Set Body=New NotesRichTextItem(doc,"Body")
> Call Body.AppendDocLink(doc,"Please Click this Link to open the
> Document")
>
> Select Case doc.txtStatus(0)
>
> Case "Draft"
> Call Body.AppendText(" CAR for action Please follow this document
> link for details. Please accept or reject as appropriate ")
> Call doc.Send (False, uidoc.FieldGetText("txtRecipient"))
> uidoc.EditMode = True
> Call Body.AppendText("**********This is a copy of a recent CAR for
> your information*********")
> Call doc.Send(False, uidoc.FieldGetText("txtCopyTo"))
> Call uidoc.FieldSetText("txtstatus", "Submitted for Acceptance")
> uiDoc.Save
> Uidoc.Close
>
> Case "Accepted - In Progress"
>
> If user = Recipient Then
> Call Body.AppendText(" CAR for validation")
> Verifier = sbmtVerifiers(VerifierChosen)
> 'Call doc.Send (False, sbmtVerifiers(VerifierChosen))
> 'Call uidoc.FieldSetText("Verifier",Verifier)
> Call doc.Send(False, Verifier)
> Call uidoc.FieldSetText("txtstatus", "Submitted for Validation")
>
> uiDoc.Save
> Uidoc.Close
> Else
> Messagebox("Only the recipient can send documents for validation!")
> Call uidoc.FieldSetText("saveoptions", "0")
> uidoc.Close(True)
> continue = False
> End If
>
> Case "Rejected"
> If User = Sender Then
> Call Body.AppendText(" CAR for action Please follow this document
> link for details. Once Accepted please agree a CAR date for completion
> ")
> Call doc.Send (False, uidoc.FieldGetText("txtRecipient"))
> uidoc.EditMode = True
> Call uidoc.FieldSetText("txtstatus", "Submitted for Acceptance")
> uiDoc.Save
> Messagebox("Thank you, the CAR has now been submitted")
> Uidoc.Close
> Else
> Messagebox("Only the originator can send documents for action!")
> Call uidoc.FieldSetText("saveoptions", "0")
> uidoc.Close(True)
> continue = False
> End If
>
> Case "Validation rejected"
> If User = Recipient Then
> Call Body.AppendText(" CAR for validation")
>
> Call doc.Send (False, sbmtVerifiers(VerifierChosen))
> uidoc.EditMode = True
> Call uidoc.FieldSetText("txtstatus", "Submitted for Validation")
> uiDoc.Save
> Uidoc.Close
> Else
> Messagebox("Only the originator can send documents for
> validation!")
> Call uidoc.FieldSetText("saveoptions", "0")
> uidoc.Close(True)
> continue = False
> End If
> End Select
> End Function
>

Reply With Quote
  #3  
Old 11-05-2008, 06:17 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sending mail with script (excluding attachment from form)

On 4 Nov, 22:49, ltony wrote:
> what is doc ??
> Wher do you set it?
> is it the same document opened in the workspace or another one you created?
>
> mj ha scritto:



Hi Itony,

Dim doc As notesdocument
Dim uidoc As notesuidocument
Reply With Quote
  #4  
Old 11-05-2008, 06:20 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sending mail with script (excluding attachment from form)

On 5 Nov, 10:17, mj wrote:
> On 4 Nov, 22:49, ltony wrote:
>
> > what is doc ??
> > Wher do you set it?
> > is it the same document opened in the workspace or another one you created?

>
> > mj ha scritto:

>
> Hi Itony,
>
> Dim doc As notesdocument
> Dim uidoc As notesuidocument



Forgot to add the declaration and the script is set in the script
library.
I am sure it's something simple to do with the way I have declared and
set the doc and uidoc, I am not used to notes script that much as my
background is in vb.net.

Thanks in advance
Reply With Quote
  #5  
Old 11-05-2008, 10:53 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: Sending mail with script (excluding attachment from form)

Just to clarify the problem, you want to send an email with a doclink
to the original document. However, the email contains an attachment
from the original document.

If this is the case, the problem is that you are using the original
document as the 'mail' document.

What you need is to create a new 'temporary' document and use it to
send...


Dim session As New NotesSession
Dim ws As New NotesUIworkspace
Dim Sender As String
Dim Recipient As String
Dim user As String
Dim verifier As Variant

' ***
dim docMail as NotesDocument
dim Body as NotesRichTextItem
'***


Set uidoc=ws.CurrentDocument
Set doc=uidoc.document
User = session.CommonUserName
Recipient = uidoc.FieldGetText("Recipient")
Sender = uidoc.FieldGetText("txtname")
uidoc.Save


set docMail = new NotesDocument(doc.ParentDatabase)
docMail.ReplaceItemValue "Form", "Memo"
docMail.ReplaceItemValue "Subject", "Corrective Action
Request"

Set Body=New NotesRichTextItem(docMail,"Body")
Call Body.AppendDocLink(doc,"Please Click this Link to open
the
Document")

select case doc.GetItemValue("txStatus")(0)
.... from now on, you use the docMail to send ... eg Call
docMail.Send(False, Verifier)


end select

delete Body = nothing ' clean up
delete docMail ' clean up - note: there is no need to save
docMail as it is only temoprary for sending




Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 02:27 AM.