HANDLE NotesHelper::CreateNotesMessage(const std::tstring& toRecipients, const std::tstring& ccRecipients, const std::tstring& bccRecipients, const std::tstring& subject, const std::tstring& body, const std::tstring& from) { InitialiseSession(); NOTEHANDLE hMemo = 0; if(NOERROR != NSFNoteCreate(m_hMailBox, &hMemo)) throw CppUnitException(_T("Failed to create a note"), __LINE__, _T(__FILE__)); try { SetMemoText(hMemo, FIELD_FORM, MAIL_MEMO_FORM); SetMemoText(hMemo, MAIL_ENTERSENDTO_ITEM, Workshare::Conversions::T22A(toRecipients.c_str())); SetMemoText(hMemo, MAIL_ENTERCOPYTO_ITEM, Workshare::Conversions::T22A(ccRecipients.c_str())); SetMemoText(hMemo, MAIL_ENTERBLINDCOPYTO_ITEM, Workshare::Conversions::T22A(bccRecipients.c_str())); SetMemoText(hMemo, MAIL_FROM_ITEM, Workshare::Conversions::T22A(from.c_str())); SetMemoText(hMemo, MAIL_SUBJECT_ITEM, Workshare::Conversions::T22A(subject.c_str())); SetMemoText(hMemo, MAIL_BODY_ITEM, Workshare::Conversions::T22A(body.c_str())); SetMemoText(hMemo, MAIL_DELIVERYPRIORITY_ITEM, "Normal"); SetMemoText(hMemo, MAIL_DELIVERYREPORT_ITEM, "Basic"); SetMemoText(hMemo, MAIL_RETURNRECEIPT_ITEM, "No"); TIMEDATE tdCurrent; OSCurrentTIMEDATE(&tdCurrent); SetMemoDate(hMemo, MAIL_COMPOSEDDATE_ITEM, tdCurrent); SetMemoDate(hMemo, MAIL_POSTEDDATE_ITEM, tdCurrent); STATUS status = NSFNoteUpdate(hMemo, UPDATE_FORCE); if(NOERROR != status) throw CppUnitException(_T("Failed to update the note"), __LINE__, _T(__FILE__)); return hMemo; } catch(...) { NSFNoteClose(hMemo); return 0; } }
DWORD CLotusNote::Update(WORD flags) { if (m_hnote == NULL) return Error_Handle("CLotusNote::Update"); return CLotusSection::Add_NApi_code_msg(NSFNoteUpdate(m_hnote,flags),SSIZE(m_err_msg),"CLotusNote::Update->NSFNoteUpdate"); }
/** eus_ReplaceDesignNote( *** Replaces the specified design-element note in a target database with its given counterpart in a source database. Any "Do Not Replace/Refresh" property on the design note in the target database is ignored. Upon replacement, any specified design-class property is set and the "Do Not Replace/Refresh" property is set to false. --- parameters & return ----- h_DB_TARGET: handle to the target database us_NOTE_CLASS: the class of the note to be removed from the target database and, if the class is a unique-note class and the source NoteID was not provided (nid_SRC), the class of the replacement note in the source database pc_NOTENM: Optional. Pointer to the name of the design-element note to be removed from the target database. Required if the note class (us_NOTE_CLASS) is not of the unique-note type. If the note class is of the unique-note type, the parameter is ignored. h_DB_SRC: handle to the source database nid_SRC: Optional. NoteID of the replacement design-element. Required if the note class is not of the unique-note type. If of the unique-note type and not provided, procedure will look up the counterpart replacement note using the note-class parameter. pc_CLASSTITLE: Optional. For design element of non-unique type, pointer to the design-class name to use if the caller wishes to set the design-class property on the replacement design element. For icon notes, parameter serves instead as a flag to indicate whether the $TITLE item on the icon note to be replaced should replace the $TITLE item on the replacement note. (The $TITLE item contains the database title, class name, design-class name and database categories associated with the database.) Parameter is ignored if the class specified in us_NOTE_CLASS is of a different unique type. Pass NULL or the null-string if no design-class name should be set. pnid: Optional Output. Address of the variable in which to store the NoteID of the replacement note in the target database after replacement has been accomplished. If NULL on pass, output is suppressed. RETURN: eus_SUCCESS if no error occured ERR_MEMORY if insufficient-memory condition is encountered the Notes API error code otherwise --- suggested enhancement --- 9/12/99 PR: incorporate flag input for whether to honor the "Do Not Replace/Refresh" property before carrying out the replacement --- revision history -------- 2/22/00 PR + minor documentation adjustment + to prevent "corrupted note" error message in Notes 4.5.1 client, added OPEN_EXPAND flag when opening notes to be signed 9/12/99 PR + recast to accommodate replacement of any design element + completed standard documentation + moved into standard library 1/22/99 PR: created */ STATUS eus_ReplaceDesignNote( DBHANDLE h_DB_TARGET, const WORD us_NOTE_CLASS, char pc_NOTENM[], DBHANDLE h_DB_SRC, const NOTEID nid_SRC, char pc_CLASSTITLE[], NOTEID *const pnid) { const BOOL f_SPECIAL_DESIGN_NOTE = !!(us_NOTE_CLASS & NOTE_CLASS_SINGLE_INSTANCE); NOTEID nid, nid_src; NOTEHANDLE h; STATUS us_err; if (! ( h_DB_TARGET && us_NOTE_CLASS && (!pc_NOTENM ? f_SPECIAL_DESIGN_NOTE : TRUE) && h_DB_SRC && h_DB_TARGET != h_DB_SRC && (!f_SPECIAL_DESIGN_NOTE ? nid_SRC : TRUE))) return !eus_SUCCESS; if (pnid) *pnid = NULL; //if this is a unique design note we're replacing and we don't yet // have the NoteID of the replacement note, get that NoteID if (!(nid_src = nid_SRC) && f_SPECIAL_DESIGN_NOTE) if (us_err = NSFDbGetSpecialNoteID( h_DB_SRC, (WORD) (SPECIAL_ID_NOTE | us_NOTE_CLASS), &nid_src)) return us_err; //if we're replacing an icon note but the caller wishes to preserve the // current set of database information (e.g. its title)... if (NOTE_CLASS_ICON == us_NOTE_CLASS && pc_CLASSTITLE) { const WORD US = (WORD) strlen( FIELD_TITLE); BLOCKID bid; //open the icon note to be replaced if (us_err = NSFDbGetSpecialNoteID( h_DB_TARGET, (WORD) (SPECIAL_ID_NOTE | NOTE_CLASS_ICON), &nid)) { if (ERR_SPECIAL_ID != us_err) return us_err; }else { if (us_err = NSFNoteOpen( h_DB_TARGET, nid, NULL, &h)) return us_err; //if the $TITLE item for some reason isn't present... if (us_err = NSFItemInfo( h, FIELD_TITLE, US, &bid, NULL, NULL, NULL)) { if (ERR_ITEM_NOT_FOUND != us_err) goto errJump; //delete the icon note from the target database in // preparation for ensuing replacement NSFNoteClose( h); if (us_err = NSFNoteDelete( h_DB_TARGET, nid, NULL)) return us_err; //else undertake preservation of the original $TITLE item... }else { NOTEHANDLE h_mem; //create a holder note in memory and place a copy of the item // in it if (us_err = NSFNoteCreate( h_DB_TARGET, &h_mem)) goto errJump; if (us_err = NSFItemCopy( h_mem, bid)) { NSFNoteClose( h_mem); goto errJump; } //close the icon note to be replaced, then carry out the // replacement NSFNoteClose( h); if (us_err = NSFNoteDelete( h_DB_TARGET, nid, NULL)) { NSFNoteClose( h_mem); return us_err; } if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) { NSFNoteClose( h_mem); return us_err; } //open the new icon note in the target database and remove // its $TITLE item if (us_err = NSFNoteOpen( h_DB_TARGET, nid, OPEN_EXPAND, &h)) { NSFNoteClose( h_mem); return us_err; } if (us_err = eus_RemoveItem( h, FIELD_TITLE, ebid_NULLBLOCKID)) { NSFNoteClose( h_mem); goto errJump; } //copy the in-memory note's $TITLE item to the icon note, // then close the in-memory note if (us_err = NSFItemInfo( h_mem, FIELD_TITLE, US, &bid, NULL, NULL, NULL)) { NSFNoteClose( h_mem); goto errJump; } us_err = NSFItemCopy( h, bid); NSFNoteClose( h_mem); if (us_err) goto errJump; //sign & save the new icon note if (us_err = NSFNoteSign( h)) goto errJump; if (us_err = NSFNoteUpdate( h, NULL)) goto errJump; } //if (us_err = NSFItemInfo( h, FIELD_TITLE, } //if (us_err = NSFDbGetSpecialNoteID( h_DB_TARGET, //if $TITLE preservation failed because the icon note or the item // itself wasn't present... if (us_err) { //open, sign, save & close the icon note in the source database if (us_err = NSFNoteOpen( h_DB_SRC, nid_src, OPEN_EXPAND, &h)) return us_err; if (us_err = NSFNoteSign( h)) goto errJump; if (us_err = NSFNoteUpdate( h, NULL)) goto errJump; NSFNoteClose( h); //copy the replacement note over to the target database if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) return us_err; } //if (us_err) //else follow a regular replacement process... }else { //delete the design note from the target database if (us_err = eus_RemoveDesignNote( h_DB_TARGET, us_NOTE_CLASS, pc_NOTENM)) return us_err; //copy the note in the template to the target database if (us_err = NSFDbCopyNote( h_DB_SRC, NULL, NULL, nid_src, h_DB_TARGET, NULL, NULL, &nid, NULL)) return us_err; //if requested, change the inheritance name on the form to the class // name provided and ensure that the flag "Do not allow // Replace/Refresh to modify" is not set if (pc_CLASSTITLE && *pc_CLASSTITLE && !f_SPECIAL_DESIGN_NOTE) { char * pc_flags; if (us_err = NSFNoteOpen( h_DB_TARGET, nid, NULL, &h)) return us_err; if (us_err = eus_RemoveItem( h, DESIGN_CLASS, ebid_NULLBLOCKID)) goto errJump; if (us_err = NSFItemSetText( h, DESIGN_CLASS, pc_CLASSTITLE, (WORD) strlen( pc_CLASSTITLE))) goto errJump; if (us_err = eus_AttemptCopyTextItemContent( h, DESIGN_FLAGS, NULL, &pc_flags, NULL)) goto errJump; if (pc_flags) { char * pc = strrchr( pc_flags, DESIGN_FLAG_PRESERVE); if (pc) { if (us_err = eus_RemoveItem( h, DESIGN_FLAGS, ebid_NULLBLOCKID)) { free( pc_flags); goto errJump; } memmove( pc, pc + 1, pc_flags + strlen( pc_flags) - pc + 1); if (us_err = NSFItemSetText( h, DESIGN_FLAGS, pc_flags, (WORD) strlen( pc_flags))) { free( pc_flags); goto errJump; } } //if (pc) free( pc_flags); } //if (pc_flags) if (us_err = NSFNoteSign( h)) goto errJump; us_err = NSFNoteUpdate( h, NULL); errJump: NSFNoteClose( h); } //if (pc_CLASSTITLE && *pc_CLASSTITLE) } //if (NOTE_CLASS_ICON == us_NOTE_CLASS && if (pnid && !us_err) *pnid = nid; return us_err; } //eus_ReplaceDesignNote(