Author is missing in Cc Field after sending mail

Hi All, We have an agent which popups a dialogbox ,in which the “To”,“Cc” and “Subject” fields are populated and a mail is sent to the users listed in “To” and “Cc” fields.

   As of now we don't have any issues with "To" field.In "Cc" field we are getting the  Admin Name and the Author of the document.At the time of debugging we are able to see the Admin Name and Author Name .Even at the time of populating also..its populating correctly.But after sending mail..If i check my mail box..I see only Admin in the cc field.Author is missing in the "Cc".I have tested many times.Once i am getting both the users in "Cc" and some times only Admin.Can any one suggest whats the problem?

Below is my code.

Sub Sendmail(fru As Variant,div As Variant,auth As NotesName)

Dim session As New NotesSession

Dim wrk As New NotesUIWorkspace

Dim doc As NotesDocument, dialogdoc As NotesDocument

Dim flag As Integer

Dim maildoc As NotesDocument

Dim body1 As NotesRichTextItem

Dim rti As NotesRichTextItem

Dim nam As NotesName

Dim nam1 As NotesName

Dim achanta As String



Set db = session.currentdatabase

Set nam= New NotesName(session.Username)

Set nam1= New NotesName(auth.Abbreviated)

achanta=auth.abbreviated



Set dialogdoc = New NotesDocument(cur_db)

	dialogdoc.Form = "dlgSendForm"

	dialogdoc.fldSubject=div + " " +fru

dialogdoc.fldCC= achanta + " , "+ nam.Abbreviated

	flag = wrk.DialogBox("dlgSendForm" , True , False , False , False , False , False , "Update Field Value" , dialogdoc, True)



	Dim temp As Variant

	Dim i As Integer

	Dim j As Integer

	Dim success As Boolean

	If flag Then



	Set maildoc = db.Createdocument()





	Set rti = New NotesRichTextItem(maildoc, "Body")

	maildoc.form = "Memo"

	maildoc.subject = dialogdoc.fldSubject(0)

	'assigning the send to

	For i=0 To UBound(dialogdoc.fldTO)

		ReDim Preserve mth1(i) As String

		'ReDim Preserve mth2(i) As String

		mth1(i)=dialogdoc.fldTO(i)



	Next

	For j=0 To UBound(dialogdoc.fldCC)



		ReDim Preserve mth2(j) As String



		mth2(j)=dialogdoc.fldCC(j)

	Next

	maildoc.Sendto=mth1

	maildoc.CopyTo=mth2

	MsgBox maildoc.CopyTo(0)

	Dim test As String

	test=dialogdoc.fldBody(0)



	Call rti.Appendtext(test)

	Call maildoc.Send(False)

	

End If

End Sub

Subject: Author is missing in Cc Field after sending mail

This is your primary problem:

dialogdoc.fldCC= achanta + " , "+ nam.Abbreviated

You are concatenating two values into a single string, but the data needs to be an array in order to work properly, something like this:

dim ccVar(1) as string

ccVar( 0 ) = achanta

ccVar( 1 ) = nam.Abbreviated

The following line of code should only be included if fldCC is not editable (or if it is editable and you don’t care whether the user decides not to include them)

dialogdoc.fldCC = ccVar

HOWEVER - If fldCC is editable on the dialog box, you can’t guarantee that these values will be there after the user clicks OK. So if it is editable, you should not set the dialogdoc field to these values, you should be adding these values to whatever the user selected after the user submits the dialog box. If you want to ensure that those two values are always in the CC field, do not include them on the dialog box field.

If fldCC is not editable, you need to populate the above array into the field on the mail doc and ignore fldCC

I would get rid of the following code as it is unecessary. You can directly assign the field values from the dialog documet to the mail document (assuming that you have correctly defined the fields on the dialog box as multi-value fields):

For i=0 To UBound(dialogdoc.fldTO)

ReDim Preserve mth1(i) As String

'ReDim Preserve mth2(i) As String

mth1(i)=dialogdoc.fldTO(i)

Next

For j=0 To UBound(dialogdoc.fldCC)

ReDim Preserve mth2(j) As String

mth2(j)=dialogdoc.fldCC(j)

Next

maildoc.Sendto=mth1

maildoc.CopyTo=mth2

Replace it with one of the following:

If fldCC is not editable and should always contain the two values you mention throughout your post, you can just do this:

Call maildoc.ReplaceItemValue( “SendTo”, dialogdoc.GetItemValue( “fldTo” ) )

Call maildoc.ReplaceItemValue( “CopyTo”, ccVar )

IF fldCC is editable on the dialog box, you need something like this to include user input and your standard values:

dim item as Notes Item

dim cc1 as variant, cc2 as variant

set item = dialogdoc.GetFirstItem( “fldCC” )

set cc1 = item.Values

if cc1( 0 ) <> “” then ’ check to see if user selected anything and if so, append user input with standard values

cc2 = arrayappend( cc1, ccVar )

else ’ if user didn’t input anything, just set to standard values

cc2 = ccVar

end if

Call maildoc.ReplaceItemValue( “CopyTo”, cc2 )

Call maildoc.ReplaceItemValue( “SendTo”, dialogdoc.GetItemValue( “fldTo” ) )

CAVEAT: This code has not been tested, but should be close to what you need to achive the desired result.

Subject: RE: Author is missing in Cc Field after sending mail

Hi Martha, Thank u for your response.I tried that way and it didn’t work out. I am getting Cc sometimes and sometimes it doesn’t work out. I am not sure what exactly is happening…